-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathssh.lua
More file actions
54 lines (44 loc) · 1.54 KB
/
Copy pathssh.lua
File metadata and controls
54 lines (44 loc) · 1.54 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
local component = require("component")
local event = require("event")
local term = require("term")
local modem = component.modem
local port = 400
local timeout = 5
modem.open(port)
modem.broadcast(port, "ls -la")
print("--- SNIFFER ACTIVE (Port 400) ---")
print("Press Ctrl+C to stop.")
while true do
-- Pull ANY event, not just modem_message, to see if anything is happening
local e = {event.pull(10)} -- 10 second timeout per loop
if e[1] == "modem_message" then
print("\n[PACKET RECEIVED]")
print("1. Event Name: " .. tostring(e[1]))
print("2. Local Addr: " .. tostring(e[2]):sub(1,8) .. "...")
print("3. Remote Addr: " .. tostring(e[3]):sub(1,8) .. "...")
print("4. Port: " .. tostring(e[4]))
print("5. Distance: " .. tostring(e[5]))
print("6. Data/Msg: " .. (tostring(e[6]) or "NIL"))
elseif e[1] == nil then
print("... still waiting (no packets) ...")
else
print("Ignored event: " .. tostring(e[1]))
end
end
-- print("Enter command to send to remote machine:")
-- local command = term.read():gsub("\n", "")
-- if command ~= "" then
-- print("Sending: " .. command)
-- modem.broadcast(port, command)
-- print("Waiting for response...")
-- local _, _, sender, p, _, response = event.pull(timeout, "modem_message", nil, nil, port)
-- if response then
-- print("\n--- Remote Output ---")
-- print(response)
-- print("---------------------")
-- else
-- print("Error: Request timed out. No response from remote machine.")
-- end
-- else
-- print("Cancelled.")
-- end