Note 1: This tool is only for research and learning purposes, please do not use the tool for bad purposes and perform illegal acts.
Join the channel Telegram of the AnonyViet 👉 Link 👈 |
Note 2: This article is for you to familiarize yourself with Python and Python Modules, not to write a DDoS Tool to attack others, when finished, absolutely do not use the Tool on a system that is not managed by your friend.
Note 3: Actually this is Tool DoS, not DDoS, I write DDoS in the title so that you can easily distinguish between Deny of service and MS-DOS
Today I will show you how to make a simple TCP Flood tool in Python. This is a pretty powerful tool that can make your computer or your computer that want to attack will be flooded with some spam packets that are sent and cause the CPU to increase up to 100%. If the device is weak, it will probably crash or buy a new one.
Before going into writing tools, I want to give you an understanding of Dos and the advanced of DoS is DDoS. So, what is Dos? And how does DoS work? You need to read carefully What is DDOS post? before practicing the content below.
First you have to Download Python. You can go to Youtube to see how to download and download Python, it’s also quite simple, I don’t guide in this article.
Install Python: At the first installation screen, remember to check the line Add python xx to path
Now open CMD on your Windows machine and enter the command: pip install termcolor
this is a font color library only, and those who don’t like it can skip it.
Because this is a DoS Tool, using resources from your Modem and PC, it only works well in a LAN environment, if it attacks outside, it is quite weak and sometimes counter-damaged.
Ok, now you will import the following modules:
After the import is complete, you proceed to decorate the interface for the tool, this is a beautiful decoration, and anyone who does not like decoration can write code.
Those of you who want to decorate like me can go to google and type keywords figlet online Then go to any website to get samples.
As you can see, the code os.system('cls')
This is the line of code that executes the command on the system’s cmd, when you run the tool, this code will delete all the existing letters on the cmd, leaving only the big DOS text below.
Well, there’s one more problem, word colored
This is a module of termcolor and you notice that there are words like ‘red’, ‘green’, ….. at the end of the code, that is the color of the text that you want to print.
OK, so let’s take the next step:
Now we write a short piece of code to get user input or “input”.
Here, you can create any variable, then we will take the user input.
You can see it,str
is a character string in Python, so because IP numbers often have different character strings separated by dots, I set it as ‘str’. And ‘int’ stands for Internet to be a data type, used in Python to represent integers.
Like that is done. Now I will proceed to decorate the attack part. I decorate it to see for my father, and if you don’t like it, you can ignore it.
Ok, this is the code interface when the tool works to attack. The first sentence of code, the second sentence of code and the font color library have already been explained, so that’s it.
Now on to the most important issue for the tool to work here.
You proceed to create yourself a function and any 2 variables as shown in the picture.
Here I create a function named syn()
and 2 variables named hevin
and bb
.
You see variable 1. I called the random module available in Python and imported it in the first step, after the word random is the word random. urandom
both are random hash functions Implemented a pseudo-random number generator and contains functions that allow us to directly solve many different programming problems using randomness. What about variables? bb
I leave the integer as 0.
Come on, let’s create a loop for yourself while True:
This is a loop that helps a certain piece of code work over and over again until I want to stop.
Now you make a pair try, except
to catch errors in Python:
First I create a variable named h
in that variable I called the built-in socket module in Python. Socket are endpointsincubateamot communication channelunmarketablep two chiyesu. It willeh dmoundng to kunmarketabletnohiveh?imoonlyughother program onlyyesy per mot other computers on the Internet. USAoonlyughprogramyesyou caneh? Seh dmoundchildrenyesu socket same mot time,uh Doh yeahyesu chughthe program caneh? Seh dmoundInternet with meot time.
Tinext is h.connect
This is me connecting to the ip and port of the attacker machine
Next is h.send(hevin)
I use this code to send the victim’s computer random parameters from 0 to 900, that’s enough, and if you want to adjust it higher, you can.
Next up :>>, that is Jaw range()
in Python which is used to create an object containing elements that are a sequence of consecutive numbers from 0 to a value, whose value does not pass the specified argument you created the input for. user input
The next code, I explained earlier, now we will explain bb+=1
Please:
The code sentence can be translated as “add anything to the right of .” +=
into the variable to the left of the . sign +=
.
Eg. If you havea = 10
then a += 5
will: a = a + 5
So “a” now equals 15.
The remaining part in
I have already explained it above
Let’s get to the ‘except’ part
Here I use KeyboardInterrupt
to fix errors when stopping the tool. To stop the tool we press the key combination Ctrl+C to stop. And if you don’t like it, you can use it except:
it’s okay.
Go to section h.close()
i called the function close()
so that every time it stops, the tool will stop running. The remaining part print(….)
I will explain through that every time you stop the tool, it will appear Done
.
Until the very end!!!!
At the end is the part for i in range(thread)
I also explained it to you as above, so skip it
Next to the last 2 lines of code, I proceeded to call module threads
Available in Python this is a multithreaded module. That way we can understand Thread is a basic unit in CPU. A thread will share with other threads in the same process about its data information, data. Thread creation makes it possible for programs to run multiple jobs at the same time.
Not only that, Python provides thread Module and threading Module so that you can start a new thread as well as some other tasks during multi-threaded programming. Each Thread has a common life cycle of start, run and end. A Thread can be interrupted (interrupt), or be temporarily stopped (sleeping) while other Threads are running – this is called yielding.
Summary of the above Code DoS you have download from Github mine. But I recommend that you practice the code according to the instructions above to better understand Python instead of pre-downloaded to use, so it will not improve programming knowledge.
How to use the Tool:
After you’re done, open cmd on your computer and point to the file you’ve placed (name).py and then enter the command.
python (name).py
Now the interface of the tool you have done will appear on the cmd screen asking you to enter the parameters: IP of the machine to attack, Port (port) computer, Threads (attack stream), Packet (number of packages to send).
Attack Result:
As you can see, I entered extremely low parameters but the result of the attack was very effective. Please note when testing on your own machine =). I left it for more than 5 seconds and my computer got up to 76% CPU
SO I HAVE TUTORIED YOU TO FINISHED HOW TO WRITE TOOL DOS IN PYTHON. Hope you will start learning Python basics with this article. I hope you should not use this Dos tool for bad purposes, instead, you can study how to prevent and prevent it.
Author: Van Son