loudcloud loudcloud - 1 year ago 67
Python Question

Why argument has been changed when using subprocess(python) to start application(windows)?

I use the python code below to start debugger and the application(a simple code I write myself) with argument:

debugger=r'C:\Program Files (x86)\Windows Kits\10\Debuggers\x86\windbg.exe'
argument='\x01\x02...\xff'#from 0x01 to 0xff

subprocess.Popen(debugger+" "+exe+" "+argument)

Well it worked, but when I set a breakpoint in main function, and checked the argument, it seemed that argv[1] is not exactly right:

enter image description here

It seems that '\x09' and '\x20' are changed to '\x00' and '\x22' is gone.

So what's wrong? Am I doing it in a wrong way?

Answer Source

Command with arguments shold be passed to Popen as list:

subprocess.Popen([debugger, exe, argument])
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download