pry0cc / axiom

The dynamic infrastructure framework for everybody! Distribute the workload of many different scanning tools with ease, including nmap, ffuf, masscan, nuclei, meg and many more!
MIT License
4k stars 622 forks source link

Should axiom-scp work with python threading? #470

Closed jcr7301 closed 2 years ago

jcr7301 commented 2 years ago

I'm currently getting the following errors when trying to execute multiple axiom-scp (with -v, for debugging reasons) from a python thread:

>>> opening connection using: ssh -o StrictHostKeyChecking=no -F /home/xxxx/.axiom/.sshconfig test01 rsync --server -xxxx . /home/op/lists/test.txt  (11 args)
ssh: Could not resolve hostname test01: No address associated with hostname
rsync: connection unexpectedly closed (0 bytes received so far) [sender]

Same command is working fine in the terminal. I've also saw some error related with /home/xxxx/.axiom/.sshconfig and /home/xxxx/.axiom/.sshconfig.new (I think, I haven't been able to reproduce), but basically when I execute from terminal sshconfig file is filled with all my instances but when I run from python it gets removed and there're maybe 2 instances left.

0xtavian commented 2 years ago

@jcr7301 Hm, not sure. If you can share your python code that would be helpful. Also try adding the --cache option. This will stop axiom from regenerating the SSH config every time. To only generate the SSH config run axiom-ssh --just-generate

0xtavian commented 2 years ago

@jcr7301 You might want to copy the sshconfig file to a tmp directory, then run axiom-scp with the -F flag pointing to the tmp SSH config file. This will prevent another thread from potentially overwriting the config. Thats how we do it with axiom-scan for every axiom-scp we execute.

https://github.com/pry0cc/axiom/blob/master/interact/axiom-scan#L336 https://github.com/pry0cc/axiom/blob/master/interact/axiom-scan#L558-L559

jcr7301 commented 2 years ago

It's working just with the --cache option in this scenario as I'm using axiom-scp before outside of the threading. Thanks!

jcr7301 commented 2 years ago

Doing axiom-scp with -F option fails in every way I've tried.

axiom-scp ~/xxxx/xxxx.txt 'test01':/home/op/lists/xxxx.txt -F /tmp/.sshconfig
Unexpected remote arg: xxxx01:/home/op/lists/xxxx.txt
rsync error: syntax or usage error (code 1) at main.c(1499) [sender=3.2.3]
axiom-scp -F /tmp/.sshconfig ~/xxxx/xxxx.txt 'test01':/home/op/lists/xxxx.txt
sending incremental file list
created directory /home/op/lists/xxxx.txt
//Creates directory with the file inside instead of sending the file
axiom-scp -F /tmp/.sshconfig "~/xxxx/xxxx.txt 'test01':/home/op/lists/xxxx.txt"
//Sends .sshconfig file content instead of sending the actual file
axiom-scp "~/xxxx/xxxx.txt 'test01':/home/op/lists/xxxx.txt" -F /tmp/.sshconfig
Unexpected remote arg: test01:/home/op/lists/xxxx.txt
rsync error: syntax or usage error (code 1) at main.c(1499) [sender=3.2.3]
0xtavian commented 2 years ago

@jcr7301 Sorry, try -F=. I'll see if i can fix that. Example: axiom-scp "~/xxxx/xxxx.txt 'test01':/home/op/lists/xxxx.txt" -F=/tmp/.sshconfig https://github.com/pry0cc/axiom/blob/master/interact/axiom-scp#L45

jcr7301 commented 2 years ago

This solution works fine. Thanks again.