-
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 #2
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 |
---|---|---|
|
@@ -4,9 +4,7 @@ | |
import sys | ||
import threading | ||
|
||
interested = [] | ||
interested.append(False) | ||
interested.append(False) | ||
interested = [False, False] | ||
|
||
|
||
def enter_region(process): | ||
|
@@ -33,7 +31,7 @@ def leave_region(process): | |
|
||
|
||
def proc(n): | ||
t = int(random.randint(0, 1)) | ||
t = random.randint(0, 1) | ||
Comment on lines
-36
to
+34
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
|
||
enter_region(n) | ||
time.sleep(t) | ||
leave_region(n) | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -21,13 +21,11 @@ def check_url(url, buff=None): | |
|
||
opener = urllib2.build_opener(urllib2.HTTPSHandler(context=ctx)) | ||
if buff: | ||
opener.addheaders.append(("Content-Type", "text/html;" + buff)) | ||
opener.addheaders.append(("Content-Type", f"text/html;{buff}")) | ||
else: | ||
opener.addheaders.append(("Content-Type", "text/html;")) | ||
|
||
data = opener.open(url).read() | ||
|
||
return data | ||
return opener.open(url).read() | ||
Comment on lines
-24
to
+28
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
|
||
|
||
|
||
s1 = check_url(sys.argv[1]) | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -83,21 +83,11 @@ def encode_pin_cmd(self, n, s): | |
B = 0x30 + int(N[1]) | ||
C = 0x30 + int(N[2]) | ||
D = 0x30 + int(N[3]) | ||
E = 0xFF | ||
F = 0xFF | ||
G = 0xFF | ||
H = 0xFF | ||
|
||
if l > 4: | ||
E = 0x30 + int(N[4]) | ||
if l > 5: | ||
F = 0x30 + int(N[5]) | ||
if l > 6: | ||
G = 0x30 + int(N[6]) | ||
if l > 7: | ||
H = 0x30 + int(N[7]) | ||
|
||
COMM = [ | ||
E = 0x30 + int(N[4]) if l > 4 else 0xFF | ||
F = 0x30 + int(N[5]) if l > 5 else 0xFF | ||
G = 0x30 + int(N[6]) if l > 6 else 0xFF | ||
H = 0x30 + int(N[7]) if l > 7 else 0xFF | ||
return [ | ||
Comment on lines
-86
to
+90
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
This removes the following comments ( why? ):
|
||
0xA0, | ||
0x20, | ||
0x00, | ||
|
@@ -111,9 +101,7 @@ def encode_pin_cmd(self, n, s): | |
F, | ||
G, | ||
H, | ||
] # APDU with command pkt | ||
|
||
return COMM | ||
] | ||
|
||
def crack_pin(self): | ||
"""The function just forms a APDU with the pin then sends it to the reader and waits for the status.""" | ||
|
@@ -186,12 +174,7 @@ def crack_pin(self): | |
connection = r[0].createConnection() | ||
connection.connect() | ||
|
||
if args.startpin: | ||
# n= 00274710 | ||
n = int(args.startpin) | ||
else: | ||
n = 0 | ||
|
||
n = int(args.startpin) if args.startpin else 0 | ||
Comment on lines
-189
to
+177
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
This removes the following comments ( why? ):
|
||
if args.lenght: | ||
if 4 <= int(args.lenght) <= 8: | ||
l = int(args.lenght) | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -23,6 +23,6 @@ | |
secret = row[2] | ||
issuer = row[6] | ||
|
||
data = "otpauth://totp/%s?secret=%s&issuer=%s" % (account, secret, issuer) | ||
data = f"otpauth://totp/{account}?secret={secret}&issuer={issuer}" | ||
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
|
||
img = qrcode.make(data) | ||
img.show() |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -46,7 +46,7 @@ def round(b, n, s=32): | |
try: | ||
d = h.digest(s) | ||
except: | ||
d = h.digest()[0 : s * 2] | ||
d = h.digest()[:s * 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 d | ||
|
||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -10,16 +10,14 @@ def beep(f): | |
|
||
|
||
def gettemp(): | ||
fp = open("/sys/class/thermal/thermal_zone0/temp", "r") | ||
temp = float(fp.read()) / 1000 | ||
fp.close() | ||
with open("/sys/class/thermal/thermal_zone0/temp", "r") as fp: | ||
temp = float(fp.read()) / 1000 | ||
Comment on lines
-13
to
+14
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 temp | ||
|
||
|
||
def getfan(): | ||
fp = open("/sys/devices/platform/asus-nb-wmi/hwmon/hwmon2/fan1_input") | ||
rpm = int(fp.read()) | ||
fp.close() | ||
with open("/sys/devices/platform/asus-nb-wmi/hwmon/hwmon2/fan1_input") as fp: | ||
rpm = int(fp.read()) | ||
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 rpm | ||
|
||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -40,7 +40,7 @@ def query(SQL, table_dest): | |
|
||
tmp = tmp.split(";") | ||
for sql in tmp: | ||
if sql != "" and sql != "\n": | ||
sql = sql + ";" | ||
if sql not in ["", "\n"]: | ||
sql = f"{sql};" | ||
Comment on lines
-43
to
+44
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(sql) | ||
query(sql, table_dest) |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -16,25 +16,25 @@ def binet(a,b,n): | |
|
||
""" | ||
|
||
|
||
l = 20 | ||
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 | ||
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])) | ||
except: | ||
m = "" | ||
pass | ||
sys.stderr.write(m) | ||
sys.stdout.write(m) | ||
sys.stdout.flush() | ||
sys.stderr.flush() | ||
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 | ||
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])) | ||
except: | ||
m = "" | ||
sys.stderr.write(m) | ||
sys.stdout.write(m) | ||
sys.stdout.flush() | ||
sys.stderr.flush() | ||
Comment on lines
+19
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
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -21,8 +21,7 @@ def make_request(*args): | |
|
||
|
||
def getjson(url): | ||
jdata = json.loads(make_request(url)) | ||
return jdata | ||
return json.loads(make_request(url)) | ||
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
|
||
|
||
|
||
data = getjson(url) | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -31,17 +31,16 @@ def Transpose16X16(tmp): | |
|
||
|
||
def bitshuffle(buff, mode): | ||
if len(buff) % 8 == 0: | ||
buff2 = "" | ||
if mode == 8: | ||
for i in xrange(0, len(buff) - 1, 8): | ||
buff2 += Transpose8X8(buff[i : i + 8]) | ||
elif mode == 16: | ||
for i in xrange(0, len(buff) - 1, 16): | ||
buff2 += Transpose16X16(buff[i : i + 16]) | ||
return buff2 | ||
else: | ||
if len(buff) % 8 != 0: | ||
raise Exception("Buffer must be a multiple of 8 bytes") | ||
buff2 = "" | ||
if mode == 8: | ||
for i in xrange(0, len(buff) - 1, 8): | ||
buff2 += Transpose8X8(buff[i : i + 8]) | ||
elif mode == 16: | ||
for i in xrange(0, len(buff) - 1, 16): | ||
buff2 += Transpose16X16(buff[i : i + 16]) | ||
return buff2 | ||
Comment on lines
-34
to
+43
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
|
||
|
||
|
||
if __name__ == "__main__": | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -25,32 +25,24 @@ def download_page(url): | |
import urllib.request # urllib library for Extracting web pages | ||
|
||
try: | ||
headers = {} | ||
headers[ | ||
"User-Agent" | ||
] = "Mozilla/5.0 (Windows NT 6.1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/41.0.2228.0 Safari/537.36" | ||
headers = { | ||
"User-Agent": "Mozilla/5.0 (Windows NT 6.1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/41.0.2228.0 Safari/537.36" | ||
} | ||
req = urllib.request.Request(url, headers=headers) | ||
resp = urllib.request.urlopen(req) | ||
respData = str(resp.read()) | ||
# print (len(respData) // 1024),"KB" | ||
|
||
return respData | ||
return str(resp.read()) | ||
except Exception as e: | ||
return None | ||
else: # If the Current Version of Python is 2.x | ||
import urllib2 | ||
|
||
try: | ||
headers = {} | ||
headers[ | ||
"User-Agent" | ||
] = "Mozilla/5.0 (X11; Linux i686) AppleWebKit/537.17 (KHTML, like Gecko) Chrome/24.0.1312.27 Safari/537.17" | ||
headers = { | ||
"User-Agent": "Mozilla/5.0 (X11; Linux i686) AppleWebKit/537.17 (KHTML, like Gecko) Chrome/24.0.1312.27 Safari/537.17" | ||
} | ||
req = urllib2.Request(url, headers=headers) | ||
response = urllib2.urlopen(req) | ||
page = response.read() | ||
# print (len(page) // 1024),"KB" | ||
|
||
return page | ||
return response.read() | ||
Comment on lines
-28
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. Function
This removes the following comments ( why? ):
|
||
except: | ||
return None | ||
|
||
|
@@ -86,10 +78,9 @@ def _get_all_items(page): | |
item, end_content = _get_next_item(page) | ||
if item == "no_links": | ||
break | ||
else: | ||
items.append(item) # Append all the links in the list named 'Links' | ||
# time.sleep(0.1) #Timer could be used to slow down the request for image downloads | ||
page = page[end_content:] | ||
items.append(item) # Append all the links in the list named 'Links' | ||
# time.sleep(0.1) #Timer could be used to slow down the request for image downloads | ||
page = page[end_content:] | ||
Comment on lines
-89
to
+83
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
|
||
if len(item) > 10000: | ||
break | ||
return items | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -9,12 +9,9 @@ def getinputs(addr_test, offset): | |
) | ||
f = urllib2.urlopen(req) | ||
|
||
data = "" | ||
addrs = [] | ||
|
||
for line in f: | ||
data += line | ||
|
||
data = "".join(f) | ||
Comment on lines
-12
to
+14
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
|
||
json_obj = json.loads(data) | ||
|
||
for item in json_obj["txs"]: | ||
|
@@ -23,8 +20,7 @@ def getinputs(addr_test, offset): | |
if addr != addr_test: | ||
addrs.append(addr) | ||
|
||
addrs = sorted(set(addrs)) | ||
return addrs | ||
return sorted(set(addrs)) | ||
|
||
|
||
for i in range(0, 800): | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -14,20 +14,18 @@ | |
|
||
|
||
def loadfile(f): | ||
fp = open(f, "r") | ||
d = fp.read() | ||
fp.close() | ||
with open(f, "r") as fp: | ||
d = fp.read() | ||
Comment on lines
-17
to
+18
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 d | ||
|
||
|
||
def savefile(f, data): | ||
fp = open(f, "w") | ||
fp.write(data) | ||
fp.close() | ||
with open(f, "w") as fp: | ||
fp.write(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
|
||
|
||
|
||
def json2file(f, s): | ||
json_data = str(json.dumps(s)) | ||
json_data = json.dumps(s) | ||
Comment on lines
-30
to
+28
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
|
||
savefile(f, json_data) | ||
|
||
|
||
|
@@ -41,7 +39,7 @@ def file2json(f): | |
|
||
def getold_nm(host): | ||
try: | ||
old_nm = file2json(".check_nmap.py." + host + ".cache") | ||
old_nm = file2json(f".check_nmap.py.{host}.cache") | ||
Comment on lines
-44
to
+42
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
|
||
except: | ||
old_nm = None | ||
return old_nm | ||
|
@@ -79,7 +77,7 @@ def proc_results(nm, old_nm, host, ports): | |
if a != b: | ||
output += "tcp port: %s, old_state: %s, state: %s\n" % (port, a, b) | ||
num_status = 2 | ||
output0 += "tcp %s: %s," % (port, b) | ||
output0 += f"tcp {port}: {b}," | ||
Comment on lines
-82
to
+80
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
|
||
else: | ||
num_status = 3 | ||
output = "Could not get scan results, check your firewall!" | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -45,7 +45,7 @@ def factor(N, g, P): | |
N = mpz(gmpy2.next_prime(2 ** bits) * gmpy2.next_prime((2 ** bits) + offset)) | ||
# N= 1522605027922533360535618378132637429718068114961380688657908494580122963258952897654000350692006139 | ||
|
||
while len(s) == 0: | ||
while not 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
|
||
g = random.randint(2, 2 ** bits) | ||
print("N:", N, "g:", g) | ||
s = factor(N, g, P=max_p) | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -82,9 +82,6 @@ def test2(data): | |
|
||
# test(str(bytearray((1024**2)*100))) | ||
|
||
data = "" | ||
for line in fileinput.input(): | ||
data += line | ||
|
||
data = "".join(fileinput.input()) | ||
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
|
||
test(data) | ||
test2(data) |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,11 +4,7 @@ | |
|
||
|
||
def count_ones(s): | ||
tmp = 0 | ||
for i in range(0, len(s) - 1): | ||
if s[i] == "1": | ||
tmp += 1 | ||
return tmp | ||
return sum(1 for i in range(0, len(s) - 1) if s[i] == "1") | ||
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
|
||
|
||
|
||
d = {} | ||
|
@@ -26,8 +22,6 @@ def count_ones(s): | |
|
||
data = [] | ||
for k in dict(sorted(d.items())[::-1]): | ||
for i in d[k]: | ||
data.append(i) | ||
|
||
data.extend(iter(d[k])) | ||
Comment on lines
-29
to
+25
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 line in data: | ||
print(data) |
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.
Lines
7-9
refactored with the following changes:merge-list-append
)