![]() |
|
[Python] Threading or Multiprocessing for SSH Bruteforcer - Printable Version +- Hack Forums (https://hackforums.net) +-- Forum: Tech (https://hackforums.net/forumdisplay.php?fid=444) +--- Forum: Coding (https://hackforums.net/forumdisplay.php?fid=151) +---- Forum: Software Development (https://hackforums.net/forumdisplay.php?fid=118) +---- Thread: [Python] Threading or Multiprocessing for SSH Bruteforcer (/showthread.php?tid=6082573) |
Threading or Multiprocessing for SSH Bruteforcer - mrKO - May 28, 2020 Hello, I wrote an ssh brute-forcer but it's too slow to be useful, I searched ways to fast it up but I don't know if it's better to use the Threading module or the Multiprocessing module. Code #!/usr/bin/pythonRE: Threading or Multiprocessing for SSH Bruteforcer - Lindros - May 28, 2020 Basically, you use threading when you are waiting around for IO (input/output). You use multiprocessing when you are doing a lot of CPU bound processing tasks (math calculations or something). Also, you can use Process Pool Executor or Thread Pool Executor to do a lot of the thread or processing managing for you. Makes it a lot easier. I've used it for school assignments. Which piece of your code specifically is slowing down? I'm guessing in this case it is IO? Maybe a Thread Pool Executor would be faster because as the function is waiting to be completed, it would start another and another. Threading would really speed this up i'd think. RE: Threading or Multiprocessing for SSH Bruteforcer - mrKO - May 29, 2020 Thank you very much !!! Yes I think the part that slows down my program is the part where I try connecting. RE: Threading or Multiprocessing for SSH Bruteforcer - vorticalbox - May 29, 2020 (May 29, 2020 02:59 AM)mrKO Wrote: Thank you very much !!! Yes I think the part that slows down my program is the part where I try connecting. yes, if you go down threads you will hit the GIL. This sort of thing is where async programming really shines. PHP Code change this line PHP Code change the number to increase the number of async tasks to fire off tested against my Raspberry PI 10 passwords per chunk took 3.8 s 20 password pc took 4.0 s 50 passwords pc took 4.8 s 100 passwords pc took 9.13 s 200 passwords pc took 11.16 s as you can see it scales quite will RE: Threading or Multiprocessing for SSH Bruteforcer - CD_ROM - May 29, 2020 (May 28, 2020 03:00 PM)Lindros Wrote: Basically, you use threading when you are waiting around for IO (input/output). You use multiprocessing when you are doing a lot of CPU bound processing tasks (math calculations or something). Valuable input mate! Thanks for the info. |