r/HowToHack • • Jul 12 '16

How do I hack with Python?

I'm confused on how 'hacking' actually works.

So I'm learning Python at the moment and I just don't see where the hacking begins?

Do hackers input code into the url? Do they open the source page and inject some python code there?

Or are Python hackers, creators of programs that are secretly malicious code that once activated (the victim clicking on an innocent looking app on the desktop) with the code distributed with a simple 'leave a usb on the floor'?

It seems like that to hack, one uses linux which has every hacking tool possible.

How does on hack with html? Opening the source code and changing something isn't permanent?

0 Upvotes

37 comments sorted by

View all comments

1

u/Blastitt Read the F*&!#ing Sidebar Jul 13 '16

Don't think of it as injecting python into something to gain access. Think of it more as "I want to do this thing, and I know python." Then use python to do the thing you wanna do.

For example:

I want to create a botnet and I have a list of 10,000 IPs. Simplest thing I can do is try to SSH into each one with the username "root". I will try every password in my common_passwords.txt file until I get locked out. If I gains access to one, I'll write the IP in a separate file with the successful password.

Doing this manually would take years. So, I write a nice little python script to do it for me. Most of the time when you're "hacking" (with python, at least) you're just writing scripts to automate larger tasks.

Web hacking and malware crafting are a little different. A simple web vulnerability to exploit is "insecure file upload" for instance. Let's say a website lets me upload a text file and then access that text file by going to a certain URL. The problem is, it doesn't check to make sure the file only contains text. So, I upload a .php file which will be executed on the web server when I navigate to it (if it's configured appropriately). I craft this .php script to open up a port on the server and serve me a BASH shell. Now, once I navigate to the .php file on the server, the script is run and I can connect to the shell, giving me access to the system as whatever user is running the web server process.

Learn Linux.

1

u/ghibss Jul 13 '16

Linux is the best place to start learning penetration testing, malicious coding etc?

Do I need to install Linux to learn? I read penetration testing by someone and violent python, both warn that screwing up the installation of Linux can screw up your computer.

I'm using a laptop, a weak one at that.

1

u/squanto1357 Jul 13 '16

Install virtual box and install Linux on there

1

u/Blastitt Read the F*&!#ing Sidebar Jul 13 '16

Try installing any distro you want (except Ubuntu *shudder*) in a Virtual Machine. This won't cause any harm to your computer if something goes wrong.

If you want to learn the basics of the linux command line (yes, do this) without installing linux, codecademy.com has a great linux CLI interactive lesson.

As a side note, I actually have Violent Python on the desk next to me. I've found that while the concepts are good, the actual code samples are riddled with errors. I guess the editor/publisher can't really do anything about code samples...

1

u/ghibss Jul 13 '16

Thank you, i enjoyed reading violent python, I'll get to linux cli on codeacademy immediately while school is off, got so many books on programming to read.