Closed nik-ngp closed 4 months ago
@nik-ngp honestly I don’t get the reason why to do that. Anyway, by knowing that in a Python environment works as it should, i am closing this down.
@stasinopoulos
by knowing that in a Python environment works as it should, i am closing this down
The Python code actually doesn't work. My Python skills are a bit rusty and I have provided wrong code.
The code I provided does not return output of the executed command, the file descriptors were inherited from the running process which meant that the executed command was writing directly to standard out & err. Instead of to a variable.
Here is an updated script:
import subprocess
cmd = "commix -r req.txt --ignore-stdin --batch"
# cmd = "echo 123" # <--- Works
def do(command: str) -> str:
try:
return subprocess.check_output(
command,
shell = True
).decode('utf-8')
except Exception as e:
print(e)
return 'Error'
output = do(cmd)
print(output)
This code reproduces the same behavior I am experiencing in the Golang example. If I set in my Golang code's stdout & stderr to os.Stdout & os.Stderr it would be equivalent to my initial Python example that worked.
honestly I don’t get the reason why to do that
I have a crawler that records requests with data and automatically targets them with Commix. Why would I have to crawl and run against endpoints when my script can? I am simply saving my own time.
@nik-ngp why not parsing targets (as a piped-in input) directly from your / other pentesting tools? (e.g https://x.com/commixproject/status/1525726750285733889)
@stasinopoulos I did some attempts, however, it seems that it does not support piping in raw requests.
I updated your code and now works fine.
import subprocess
url = "http://php.testsparker.com/nslookup.php?param=1"
cmd = f"commix -u {url} --batch --os-cmd=whoami --answers=\"shell=n\""
def do(command: str) -> str:
try:
return subprocess.run(
command,
shell = True
)
except Exception as e:
print(e)
return 'Error'
output = do(cmd)
print(output)
Hello @stasinopoulos. I have to admit, you got me a bit confused. I'm unsure of what the updated code is meant to represent since it deviates from the purpose of my script in two ways:
print
function which would still output Commix to the terminal.@nik-ngp just of curiosity, have you tried the same using other (similar) tools (e.g. sqlmap etc)? Anyway, I'll take a look into this issue and get back to you soon.
@stasinopoulos Indeed I am using Sqlmap to tests against raw requests. It works nicely with my code.
Potential fix: https://github.com/commixproject/commix/commit/ebe84fac8a3f06db3590fd447434627d5ffef16e. Please check again.
This issue has been automatically locked due to inactivity.
Please file a new issue if you are encountering a similar or related problem.
This action has been performed automatically by a bot.
What's the problem (or question)?
Commix has issues when running under an emulated terminal.
For example, I tried running it within Python (which does execution differently, it creates an actual process) and it worked (edit it does not):
import subprocess
cmd = "commix -r req.txt --ignore-stdin --batch"
returned_value = subprocess.call(cmd, shell=True)
print(returned_value)
How can we reproduce the issue?
https://github.com/nik-ngp/commix-bug
When I run the program in the repo I receive this in the console:
What are the running context details?