-
Notifications
You must be signed in to change notification settings - Fork 11
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Sourcery refactored master branch #4
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -30,7 +30,7 @@ | |
ssl_sock.write("AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA") | ||
print("sent...") | ||
try: | ||
print("recv:" + ssl_sock.recv(512)) | ||
print(f"recv:{ssl_sock.recv(512)}") | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Lines
|
||
except ssl.SSLError as err: | ||
if err.find("record overflow"): | ||
print("Vulnerable") | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -31,9 +31,7 @@ def check_url(url, buff=None): | |
s1 = check_url(sys.argv[1]) | ||
s2 = check_url(sys.argv[1], buff) | ||
|
||
i = list(difflib.unified_diff(s1, s2)) | ||
|
||
if len(i) > 0: | ||
if i := list(difflib.unified_diff(s1, s2)): | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Lines
|
||
print("[+] Host Vulnerable!") | ||
else: | ||
print("[-] Host Not vulnerable!") |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -12,7 +12,7 @@ | |
|
||
tmp = tempfile.mkstemp()[1] | ||
|
||
os.system("cat %s | gpg --decrypt > %s" % (sys.argv[1], tmp)) | ||
os.system(f"cat {sys.argv[1]} | gpg --decrypt > {tmp}") | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Lines
|
||
|
||
conn = sqlite3.connect(tmp) | ||
c = conn.cursor() | ||
|
@@ -21,5 +21,5 @@ | |
totp = pyotp.TOTP(row[2]) | ||
print(totp.now(), row[1]) | ||
|
||
os.system("shred %s -v" % tmp) | ||
os.system("rm %s" % tmp) | ||
os.system(f"shred {tmp} -v") | ||
os.system(f"rm {tmp}") |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -33,10 +33,10 @@ | |
ENCRYPT = 1 | ||
DECRYPT = 0 | ||
|
||
assert path.isfile(header_file), "Input file '%s' not found." % header_file | ||
assert path.isfile(encrypted_partition), ( | ||
"Input file '%s' not found." % encrypted_partition | ||
) | ||
assert path.isfile(header_file), f"Input file '{header_file}' not found." | ||
assert path.isfile( | ||
encrypted_partition | ||
), f"Input file '{encrypted_partition}' not found." | ||
Comment on lines
-36
to
+39
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Lines
|
||
header = open(header_file, "rb").read() | ||
|
||
# Unpack header | ||
|
@@ -52,7 +52,7 @@ | |
fsSize2, | ||
failedDecrypt, | ||
cryptoType, | ||
) = struct.unpack(HEADER_FORMAT, header[0:100]) | ||
) = struct.unpack(HEADER_FORMAT, header[:100]) | ||
|
||
encrypted_key = header[ftrSize : ftrSize + keySize] | ||
salt = header[ftrSize + keySize + 32 : ftrSize + keySize + 32 + 16] | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -9,7 +9,7 @@ | |
|
||
def make_request(*args): | ||
opener = urllib.request.build_opener() | ||
opener.addheaders = [("User-agent", "Mozilla/5.0" + str(random.randrange(1000000)))] | ||
opener.addheaders = [("User-agent", f"Mozilla/5.0{random.randrange(1000000)}")] | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Function
|
||
try: | ||
return opener.open(*args).read().strip() | ||
except Exception as e: | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -12,11 +12,7 @@ | |
outputfile = sys.argv[2] | ||
h = sys.argv[1] | ||
|
||
cmd = ( | ||
"%s -b %s -m %s -f %s -v -a -o %s -I" | ||
% (binary, bloomfile, tabfile, binfile, outputfile) | ||
+ " %s" | ||
) | ||
cmd = f"{binary} -b {bloomfile} -m {tabfile} -f {binfile} -v -a -o {outputfile} -I %s" | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Lines
|
||
|
||
n = 10 | ||
for i in range(1, n + 1): | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -94,8 +94,8 @@ def main(): | |
nm.scan(host, sys.argv[2], arguments="--system-dns") | ||
ports = getports(nm, host) | ||
num_status, output = proc_results(nm, old_nm, host, ports) | ||
json2file(".check_nmap.py." + host + ".cache", nm[host]) | ||
print(status[num_status] + ": " + output) | ||
json2file(f".check_nmap.py.{host}.cache", nm[host]) | ||
print(f"{status[num_status]}: {output}") | ||
Comment on lines
-97
to
+98
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Function
|
||
sys.exit(num_status) | ||
|
||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -39,7 +39,7 @@ def test(msg_data): | |
a, b, c = struct.unpack(">4si{0:d}s".format(msg_len), msg_data) | ||
print("Pack:", a, b, c.encode("hex")) | ||
new_data = zlib.decompress(c) | ||
print("Decompressed data: " + new_data) | ||
print(f"Decompressed data: {new_data}") | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Function
|
||
|
||
|
||
test("dario") |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -29,16 +29,15 @@ def Hash(x): | |
|
||
|
||
def pw_decode(s, password): | ||
if password is not None: | ||
secret = Hash(password) | ||
try: | ||
d = DecodeAES(secret, s) | ||
# d = decrypt(s,secret) | ||
except Exception as e: | ||
raise Exception("Invalid password") | ||
return d | ||
else: | ||
if password is None: | ||
return s | ||
secret = Hash(password) | ||
try: | ||
d = DecodeAES(secret, s) | ||
# d = decrypt(s,secret) | ||
except Exception as e: | ||
raise Exception("Invalid password") | ||
return d | ||
Comment on lines
-32
to
+40
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Function
|
||
|
||
|
||
def try_pw(encoded_seed, pw_cand): | ||
|
@@ -174,7 +173,7 @@ def test(): | |
|
||
seed = try_pw(encoded_seed, pw_cand1) | ||
if chk_seed(seed): | ||
print("pw is good: %s" % pw_cand1) | ||
print(f"pw is good: {pw_cand1}") | ||
Comment on lines
-177
to
+176
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Function
|
||
print(seed) | ||
cnt_good += 1 | ||
break | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -18,9 +18,7 @@ def make_crc_table(const): | |
|
||
|
||
def displaytable(table): | ||
string_hex_line = "" | ||
for i in numbers: | ||
string_hex_line += hex(i) | ||
string_hex_line = "".join(hex(i) for i in numbers) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Function
|
||
print(string_hex_line) | ||
|
||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,7 @@ | ||
import docker | ||
import sys | ||
|
||
client = docker.DockerClient(base_url="tcp://%s:2375" % sys.argv[1]) | ||
client = docker.DockerClient(base_url=f"tcp://{sys.argv[1]}:2375") | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Lines
|
||
|
||
nodes = client.nodes.list() | ||
for node in nodes: | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -63,7 +63,7 @@ def leftmost_bit(x): | |
assert x > 0 | ||
result = 1 | ||
while result <= x: | ||
result = 2 * result | ||
result *= 2 | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Function
|
||
return result / 2 | ||
|
||
e = other | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -21,4 +21,4 @@ | |
|
||
for key, value in sorted(parts): | ||
print(key, value) | ||
system("cat %s >> %s" % (value, target)) | ||
system(f"cat {value} >> {target}") | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Lines
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -18,7 +18,7 @@ def upload(ip, filename): | |
if run: | ||
ftp = FTP(ip, USER, PASS, timeout=timeout) | ||
# tp.login() | ||
ftp.storlines("STOR %s" % filename, open(filename, "r")) | ||
ftp.storlines(f"STOR {filename}", open(filename, "r")) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Function
|
||
|
||
|
||
filename = sys.argv[1] | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,8 +7,7 @@ | |
print("Algo\tSpeed") | ||
|
||
a = list(hashlib.algorithms_available) | ||
a.append("sha3_256") | ||
a.append("sha3_512") | ||
a.extend(("sha3_256", "sha3_512")) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Lines
|
||
|
||
for h in a: | ||
size = 100 | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -18,28 +18,18 @@ | |
|
||
url_base = "http://www.montevideo.gub.uy/transporteRest/" | ||
|
||
if l > 4: | ||
url = ( | ||
url_base | ||
+ "pasadas/" | ||
+ str(codigo_parada) | ||
+ "/" | ||
+ tipo_dia | ||
+ "/" | ||
+ str(linea) | ||
+ "/" | ||
+ hora | ||
) | ||
else: | ||
url = url_base + "pasadas/" + str(codigo_parada) + "/" + tipo_dia + "/" + hora | ||
|
||
url = ( | ||
f"{url_base}pasadas/{str(codigo_parada)}/{tipo_dia}/{str(linea)}/{hora}" | ||
if l > 4 | ||
else f"{url_base}pasadas/{str(codigo_parada)}/{tipo_dia}/{hora}" | ||
) | ||
j = json.loads(urllib.request.urlopen(url).read()) | ||
for pasada in j: | ||
print( | ||
"Linea:", | ||
pasada["linea"], | ||
"Hora:", | ||
str(pasada["horaDesc"]), | ||
pasada["horaDesc"], | ||
Comment on lines
-21
to
+32
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Lines
|
||
"Destino:", | ||
pasada["destino"], | ||
) |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -136,7 +136,7 @@ def calculate_best_candidate(start_date, days, franqueo): | |
last_best = 0 | ||
hs = init_holidays(dstart.year) | ||
best = [] | ||
for i in range(0, 365): | ||
for _ in range(0, 365): | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Function
|
||
# dstart += timedelta(days=1) | ||
|
||
r, d = lic(dstart, days, franqueo, hs) | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -44,7 +44,7 @@ def seeklog(A, key, imin, imax): | |
|
||
|
||
def test(): | ||
tmp = [x for x in range(1024 * 1024 * 20)] | ||
tmp = list(range(1024 * 1024 * 20)) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Function
|
||
print("res=", seeklog(tmp, 1337, 0, len(tmp))) | ||
print("count=", count) | ||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -44,22 +44,22 @@ def test(): | |
lru = LRU(4) | ||
|
||
for i in range(0, 21): | ||
lru.insert("key" + str(i), str(i)) | ||
lru.insert(f"key{str(i)}", str(i)) | ||
|
||
for i in range(0, 1000): | ||
for _ in range(0, 1000): | ||
lru.get("key13") | ||
for i in range(0, 500): | ||
for _ in range(0, 500): | ||
lru.get("key11") | ||
for i in range(0, 250): | ||
for _ in range(0, 250): | ||
lru.get("key7") | ||
for i in range(0, 125): | ||
for _ in range(0, 125): | ||
lru.get("key5") | ||
lru.get("key3") | ||
lru.get("key2") | ||
lru.get("key1") | ||
|
||
print(lru.access) | ||
for i in range(0, 3): | ||
for _ in range(0, 3): | ||
Comment on lines
-47
to
+62
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Function
|
||
lru.purge() | ||
print(lru.access) | ||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -8,7 +8,7 @@ | |
pid = int(sys.argv[1]) | ||
with open("/proc/%d/maps" % pid, "r") as maps_file: | ||
with open("/proc/%d/mem" % pid, "r", 0) as mem_file: | ||
for line in maps_file.readlines(): | ||
for line in maps_file: | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Lines
|
||
line = line.rstrip() | ||
cols = line.split(" ") | ||
print(cols) | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -27,20 +27,13 @@ | |
local_host = lhost[0] | ||
local_port = lhost[1] | ||
|
||
if opt == "-n": | ||
remote_hosts = list(ipaddress.IPv4Network(str(sys.argv[2]), strict=False).hosts()) | ||
|
||
if opt == "-f": | ||
remote_hosts = [] | ||
fp = open(sys.argv[2], "r") | ||
for line in fp: | ||
if line.find("#") == -1: | ||
remote_hosts.append(line.strip()) | ||
remote_hosts = [line.strip() for line in fp if line.find("#") == -1] | ||
elif opt == "-n": | ||
remote_hosts = list(ipaddress.IPv4Network(str(sys.argv[2]), strict=False).hosts()) | ||
|
||
for remote_host in remote_hosts: | ||
if no_ping: | ||
if not no_ping and pyping.ping(str(remote_host)) or no_ping: | ||
print(payload % (exploit, remote_host, local_host, local_port, meterpreter)) | ||
else: | ||
if pyping.ping(str(remote_host)): | ||
print(payload % (exploit, remote_host, local_host, local_port, meterpreter)) | ||
Comment on lines
-30
to
-45
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Lines
|
||
print("exit") |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -28,8 +28,7 @@ def get_json(fp, sha256s): | |
|
||
|
||
for line in fileinput.input(): | ||
data = get_json(fp, line.replace("\n", "")) | ||
if data: | ||
if data := get_json(fp, line.replace("\n", "")): | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Lines
|
||
print(data["blockchain_transaction"]["private_key"]) | ||
|
||
fp.close() |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -11,26 +11,20 @@ def PMKID(apmac, clmac, PSK, SSID): | |
|
||
|
||
REQ = "2a416a999af0a6bf454684269afb06ef" | ||
print("Required hash: %s" % REQ) | ||
print(f"Required hash: {REQ}") | ||
apmac = "34:bf:90:4a:bb:57" | ||
clmac = "98:de:d0:1a:97:c2" | ||
PSK = "786 5555" | ||
SSID = "unknown" | ||
|
||
print("SSID: [%s]" % SSID) | ||
print("PSK: [%s]" % PSK) | ||
print("AP mac: %s" % apmac) | ||
print("Cl mac: %s" % clmac) | ||
print(f"SSID: [{SSID}]") | ||
print(f"PSK: [{PSK}]") | ||
print(f"AP mac: {apmac}") | ||
print(f"Cl mac: {clmac}") | ||
print( | ||
"HASH: %s*%s*%s*%s" | ||
% ( | ||
REQ, | ||
apmac.replace(":", ""), | ||
clmac.replace(":", ""), | ||
binascii.hexlify(SSID), | ||
) | ||
f'HASH: {REQ}*{apmac.replace(":", "")}*{clmac.replace(":", "")}*{binascii.hexlify(SSID)}' | ||
) | ||
|
||
pmkid, pmk = PMKID(apmac, clmac, PSK, SSID) | ||
print("PMK: " + binascii.hexlify(pmk)) | ||
print("PMKID: " + binascii.hexlify(pmkid[0:32])) | ||
print(f"PMK: {binascii.hexlify(pmk)}") | ||
print(f"PMKID: {binascii.hexlify(pmkid[:32])}") | ||
Comment on lines
-14
to
+30
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Lines
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Function
enter_region
refactored with the following changes:use-assigned-variable
)