Skip to content

Commit

Permalink
2to3, blackify code
Browse files Browse the repository at this point in the history
  • Loading branch information
daedalus committed Jan 8, 2024
1 parent e982f66 commit 572b2bd
Show file tree
Hide file tree
Showing 98 changed files with 1,149 additions and 852 deletions.
6 changes: 3 additions & 3 deletions 2proc_pmutex.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
def enter_region(process):
global interested
k = 0
print "enter_region: %d" % process
print("enter_region: %d" % process)

other = 1 - process
interested[process] = True
Expand All @@ -20,12 +20,12 @@ def enter_region(process):
# if (k % 10000 == 0):
# print "process wait",process
continue
print "entered_critical: %d ticks %d" % (process, k)
print("entered_critical: %d ticks %d" % (process, k))


def leave_region(process):
global interested
print "leave_region: %d" % process
print("leave_region: %d" % process)

interested[process] = False

Expand Down
2 changes: 1 addition & 1 deletion CVE-2012-6636.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,4 @@
)


print payload.replace("COMMAND_HERE", sys.argv[1])
print(payload.replace("COMMAND_HERE", sys.argv[1]))
16 changes: 8 additions & 8 deletions CVE-2016-2017.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
# HOST, PORT = 'XX.XX.XX.XX', 4434

h = sys.argv[1].split(":")
print h[0], h[1]
print(h[0], h[1])


# CREATE SOCKET
Expand All @@ -23,18 +23,18 @@

ssl_sock = ssl.wrap_socket(sock, ssl_version=ssl.PROTOCOL_TLSv1, ciphers=ciphers)
ssl_sock.connect((h[0], int(h[1])))
print ssl_sock.cipher()
print(ssl_sock.cipher())
# print sock.cipher()
print "connected..."
print("connected...")
# ssl_sock.write("$")
ssl_sock.write("AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA")
print "sent..."
print("sent...")
try:
print "recv:" + ssl_sock.recv(512)
print("recv:" + ssl_sock.recv(512))
except ssl.SSLError as err:
if err.find("record overflow"):
print "Vulnerable"
print("Vulnerable")
if err.find("bad record MAC"):
print "Not Vulnerable"
print("Not Vulnerable")
ssl_sock.close()
print "closed"
print("closed")
10 changes: 5 additions & 5 deletions CVE-2017-7679.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,13 @@
# Author Dario Clavijo 2018
# GPLv3

import urllib2
import urllib.request, urllib.error, urllib.parse
import simplejson as json
import sys
import ssl
import difflib

print "[*] CVE-2017-7679 Checking url..."
print("[*] CVE-2017-7679 Checking url...")

buff = "A" * 7800
buff = "\x90" * 7800
Expand All @@ -19,7 +19,7 @@ def check_url(url, buff=None):
ctx.check_hostname = False
ctx.verify_mode = ssl.CERT_NONE

opener = urllib2.build_opener(urllib2.HTTPSHandler(context=ctx))
opener = urllib.request.build_opener(urllib.request.HTTPSHandler(context=ctx))
if buff:
opener.addheaders.append(("Content-Type", f"text/html;{buff}"))
else:
Expand All @@ -34,6 +34,6 @@ def check_url(url, buff=None):
i = list(difflib.unified_diff(s1, s2))

if len(i) > 0:
print "[+] Host Vulnerable!"
print("[+] Host Vulnerable!")
else:
print "[-] Host Not vulnerable!"
print("[-] Host Not vulnerable!")
26 changes: 13 additions & 13 deletions IEEE_754_1985_FPR.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,12 @@ def ieee_754_1985_32(i):
S = i >> 31
E = (i >> 23) & 0b11111111
F = i & 0b11111111111111111111111
a = -(1 ** S)
b = 1.0 + ((1.0 * F) / (2 ** 23))
a = -(1**S)
b = 1.0 + ((1.0 * F) / (2**23))
c = 2 ** (E - 127)
if verbose:
print bin(s), bin(E), bin(F)
print a, b, c
print(bin(s), bin(E), bin(F))
print(a, b, c)
return a * b * c


Expand All @@ -26,24 +26,24 @@ def ieee_754_1985_64(i):
S = i >> 63
E = (i >> 52) & 0b11111111111
F = i & 0b1111111111111111111111111111111111111111111111111111
a = -(1 ** S)
b = 1.0 + ((1.0 * F) / (2 ** 52))
a = -(1**S)
b = 1.0 + ((1.0 * F) / (2**52))
c = 2 ** (E - 1023)
if verbose:
print bin(s), bin(E), bin(F)
print a, b, c
print(bin(s), bin(E), bin(F))
print(a, b, c)
return a * b * c


def test():
pi = 3.141592653589793
print pi
print(pi)
pi32 = 0b01000000010010010000111111011011
pi64 = 0b0100000000001001001000011111101101010100010001000010110100011000
print pi32, hex(pi32)
print pi64, hex(pi64)
print ieee_754_1985_32(pi32)
print ieee_754_1985_64(pi64)
print(pi32, hex(pi32))
print(pi64, hex(pi64))
print(ieee_754_1985_32(pi32))
print(ieee_754_1985_64(pi64))


test()
14 changes: 8 additions & 6 deletions SIMM_Pin_Recovery.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ def runtime(self):
nd = self.nc - self.ns
ndtd = nd / td
htd = humanfriendly.format_timespan(td)
print("[+] Runtime: %s, tried pins: %d, rate: %.4f " % (htd, nd, ndtd))
print(("[+] Runtime: %s, tried pins: %d, rate: %.4f " % (htd, nd, ndtd)))

def signal_handler(self, sig, frame):
self.stoping = True
Expand Down Expand Up @@ -69,7 +69,7 @@ def xmit(self, Command):
except:
if self.stoping == False:
print(
"[!] Connection error!, last pin checked: %d." % (self.nc - 1)
("[!] Connection error!, last pin checked: %d." % (self.nc - 1))
)
self.stoping = True
r = None
Expand Down Expand Up @@ -112,8 +112,10 @@ def crack_pin(self):
s = "X%dd" % l
s = s.replace("X", "%0")
print(
"[+] startpin: %d, max: %d, wait: %s, reset: %s"
% (n, L, str(self.wait), str(self.reset))
(
"[+] startpin: %d, max: %d, wait: %s, reset: %s"
% (n, L, str(self.wait), str(self.reset))
)
)

while n <= L and self.Continue: # keep looping if the c is set
Expand Down Expand Up @@ -144,7 +146,7 @@ def crack_pin(self):
self.stoping = True

if self.Found: # Status for successful attack
print("\n\n[*] The PIN is: [ %d ]!!!" % n)
print(("\n\n[*] The PIN is: [ %d ]!!!" % n))
self.stoping = True

if self.wait != None:
Expand All @@ -170,7 +172,7 @@ def crack_pin(self):
args = parser.parse_args()

r = readers()
print("[+] Reader:", r)
print(("[+] Reader:", r))
connection = r[0].createConnection()
connection.connect()

Expand Down
2 changes: 1 addition & 1 deletion TOTP_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@

for row in c.execute("select * from accounts"):
totp = pyotp.TOTP(row[2])
print totp.now(), row[1]
print(totp.now(), row[1])

os.system("shred %s -v" % tmp)
os.system("rm %s" % tmp)
12 changes: 6 additions & 6 deletions X16Rlike.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
import binascii
import hashlib

print(hashlib.algorithms_available)
print((hashlib.algorithms_available))

algos = [
"sha1",
Expand Down Expand Up @@ -46,23 +46,23 @@ def round(b, n, s=32):
try:
d = h.digest(s)
except:
d = h.digest()[:s * 2]
d = h.digest()[: s * 2]
return d


def hash(b, s=32):
tmp = b
for x in range(0, len(b)):
n = b[x] & 0xF
print(n, algos[n])
print((n, algos[n]))
tmp = round(tmp, n, s=s)
return tmp


x = binascii.unhexlify("0" * 63 + "1")
x = hash(x)
print(binascii.hexlify(x))
print((binascii.hexlify(x)))
x = hash(x)
print(binascii.hexlify(x))
print((binascii.hexlify(x)))
x = hash(x)
print(binascii.hexlify(x))
print((binascii.hexlify(x)))
14 changes: 7 additions & 7 deletions ackermann.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,19 +4,19 @@

# naive implementation
def A(m, n):
print ">", m, n
print(">", m, n)
if m == 0:
print "<", m, n
print("<", m, n)
return n + 1
if m > 0 and n == 0:
print "<", m - 1, 1
print("<", m - 1, 1)
return A(m - 1, 1)
if m > 0 and n > 0:
print "<", m - 1, "A(", m, n - 1, ")"
print("<", m - 1, "A(", m, n - 1, ")")
return A(m - 1, A(m, n - 1))
# print "<", m,n


print A(1, 2)
print A(2, 1)
print A(2, 2)
print(A(1, 2))
print(A(2, 1))
print(A(2, 2))
2 changes: 1 addition & 1 deletion android_fde_decryptkey.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,4 +68,4 @@
decrypted_key = cipher.update(encrypted_key)
decrypted_key = decrypted_key + cipher.final()

print decrypted_key.encode("hex")
print(decrypted_key.encode("hex"))
2 changes: 1 addition & 1 deletion bigquery_batch_execute.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ def query(SQL, table_dest):
SQL, location="US", job_config=job_config
) # ,useLegacySql=False)
rows = list(query_job)
print("rows affected: %d" % len(rows))
print(("rows affected: %d" % len(rows)))


fp = open(sys.argv[1])
Expand Down
30 changes: 18 additions & 12 deletions binet_oeis_crawl.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,10 @@
import sys
import oeispy as op

def binet(a,b,n):
return ((a**n)-(b**n))/(a-b)

def binet(a, b, n):
return ((a**n) - (b**n)) / (a - b)


"""
a b resulting pol
Expand All @@ -18,23 +20,27 @@ def binet(a,b,n):


l = 20
for i in range(0,l):
for j in range(i,l):
for i in range(0, l):
for j in range(i, l):
tmp = []
if i != j:
for k in range(1,l):
try:
tmp.append(str(round(binet(i,j,k))))
except:
pass
for k in range(1, l):
try:
tmp.append(str(round(binet(i, j, k))))
except:
pass
q = ",".join(tmp)
try:
res=op.resultEois(q)
m = "a: %d, b: %d, Name: A%06d, Desc: %s\n" % (i,j,op.getNumber(res[0]),op.getName(res[0]))
res = op.resultEois(q)
m = "a: %d, b: %d, Name: A%06d, Desc: %s\n" % (
i,
j,
op.getNumber(res[0]),
op.getName(res[0]),
)
except:
m = ""
sys.stderr.write(m)
sys.stdout.write(m)
sys.stdout.flush()
sys.stderr.flush()

8 changes: 4 additions & 4 deletions bitnodes.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#!/usr/bin/env python
import urllib2
import urllib.request, urllib.error, urllib.parse
import json
import sys
import random
Expand All @@ -8,11 +8,11 @@


def make_request(*args):
opener = urllib2.build_opener()
opener = urllib.request.build_opener()
opener.addheaders = [("User-agent", "Mozilla/5.0" + str(random.randrange(1000000)))]
try:
return opener.open(*args).read().strip()
except Exception, e:
except Exception as e:
try:
p = e.read().strip()
except:
Expand All @@ -27,4 +27,4 @@ def getjson(url):
data = getjson(url)

for node in data["nodes"]:
print node
print(node)
16 changes: 8 additions & 8 deletions bitshuffle.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,21 +35,21 @@ def bitshuffle(buff, mode):
raise Exception("Buffer must be a multiple of 8 bytes")
buff2 = ""
if mode == 8:
for i in xrange(0, len(buff) - 1, 8):
for i in range(0, len(buff) - 1, 8):
buff2 += Transpose8X8(buff[i : i + 8])
elif mode == 16:
for i in xrange(0, len(buff) - 1, 16):
for i in range(0, len(buff) - 1, 16):
buff2 += Transpose16X16(buff[i : i + 16])
return buff2


if __name__ == "__main__":
a = "Dario Clavijo "
print a, len(a)
print a.encode("hex")
print bintobit(a)
print(a, len(a))
print(a.encode("hex"))
print(bintobit(a))

a = bitshuffle(a)
print a.encode("hex")
print bintobit(a)
print bitshuffle(a)
print(a.encode("hex"))
print(bintobit(a))
print(bitshuffle(a))
Loading

0 comments on commit 572b2bd

Please sign in to comment.