Skip to content

Commit 367a0e7

Browse files
authored
Merge branch 'master' into master
2 parents 2cb37c1 + c2fdd74 commit 367a0e7

25 files changed

+243
-188
lines changed

Assembler/assembler.py

-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,4 @@
11
import sys
2-
//WE NEED TSHIRT FOR HACKTOBER FEST.
3-
//PLEASE ACCEPT MY PR.
42

53
lines = [] # contains the lines of the file.
64
tokens = [] # contains all tokens of the source code.

GroupSms_Way2.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
from __future__ import print_function
12
import urllib2
23
import cookielib
34
from getpass import getpass
@@ -42,4 +43,4 @@
4243
print("Error while sending message")
4344

4445
sys.exit(1)
45-
print "SMS has been sent."
46+
print("SMS has been sent.")

Organise.py

+1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
from __future__ import print_function
12
import os
23
import sys
34
import shutil

Shivaansh.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1+
from __future__ import print_function
12
x = input("Enter a number: ")
23
for i in range (1,11,1):
3-
print x, "x", i, "=", (x * i)
4+
print(x, "x", i, "=", (x * i))
45

binary coefficients

+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
def pascal_triangle( lineNumber ) :
2+
list1 = list()
3+
list1.append([1])
4+
i=1
5+
while(i<=lineNumber):
6+
j=1
7+
l=[]
8+
l.append(1)
9+
while(j<i):
10+
11+
l.append(list1[i-1][j]+list1[i-1][j-1])
12+
j=j+1
13+
l.append(1)
14+
list1.append(l)
15+
i=i+1
16+
return list1
17+
18+
def binomial_coef(n,k):
19+
pascalTriangle=pascal_triangle(n)
20+
return(pascalTriangle[n][k-1])
21+

env_check.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -23,4 +23,4 @@
2323
if newenv is None: # If it doesn't exist
2424
print(env_check, 'is not set') # Print it is not set
2525
else: # Else if it does exist
26-
print('Current Setting for {}={}\n'.format(env_check, newenv) # Print out the details)
26+
print('Current Setting for {}={}\n'.format(env_check, newenv)) # Print out the details

get_likes_on_FB.py

+3-2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
from __future__ import print_function
12
import urllib
23
import json
34
import sys
@@ -12,7 +13,7 @@
1213
data = json.load(urllib.urlopen(url))
1314
id=0
1415

15-
print str(id)
16+
print(str(id))
1617

1718
for item in data['data']:
1819
time=item['created_time'][11:19]
@@ -32,4 +33,4 @@
3233

3334
id+=1
3435

35-
print str(id)+'\t'+ time.encode('utf-8')+'\t'+date.encode('utf-8')+'\t'+year.encode('utf-8')+'\t'+ str(num_share)+'\t'+str(num_like)
36+
print(str(id)+'\t'+ time.encode('utf-8')+'\t'+date.encode('utf-8')+'\t'+year.encode('utf-8')+'\t'+ str(num_share)+'\t'+str(num_like))

merge.py

+3-2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
from __future__ import print_function
12
# author:zhangshuyx@gmail.com
23

34
#!/usr/bin/env python
@@ -32,8 +33,8 @@ def merge():
3233
# the main program
3334

3435
def main():
35-
print "\t\tMerge\n\n"
36-
print "This program merges csv-files to one file\n"
36+
print("\t\tMerge\n\n")
37+
print("This program merges csv-files to one file\n")
3738
merge()
3839

3940
if __name__ == '__main__':

new_script.py

+4-3
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
from __future__ import print_function
12
# Script Name : new_script.py
23
# Author : Craig Richards
34
# Created : 20th November 2012
@@ -19,11 +20,11 @@
1920
-sql : SQL Script'''
2021

2122
if len(sys.argv) < 3:
22-
print text
23+
print(text)
2324
sys.exit()
2425

2526
if '-h' in sys.argv or '--h' in sys.argv or '-help' in sys.argv or '--help' in sys.argv:
26-
print text
27+
print(text)
2728
sys.exit()
2829
else:
2930
if '-python' in sys.argv[1]:
@@ -39,7 +40,7 @@
3940
config_file = "sql.cfg"
4041
extension = ".sql"
4142
else:
42-
print 'Unknown option - ' + text
43+
print('Unknown option - ' + text)
4344
sys.exit()
4445

4546
confdir = os.getenv("my_config")

nmap_scan.py

+3-2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
from __future__ import print_function
12
# Script Name : nmap_scan.py
23
# Author : Craig Richards
34
# Created : 24th May 2013
@@ -16,7 +17,7 @@ def nmapScan(tgtHost, tgtPort): # Create the function, this fucntion doe
1617
nmScan = nmap.PortScanner()
1718
nmScan.scan(tgtHost, tgtPort)
1819
state = nmScan[tgtHost]['tcp'][int(tgtPort)]['state']
19-
print "[*] " + tgtHost + " tcp/" + tgtPort + " " + state
20+
print("[*] " + tgtHost + " tcp/" + tgtPort + " " + state)
2021

2122

2223
def main(): # Main Program
@@ -28,7 +29,7 @@ def main(): # Main Program
2829
tgtPorts = str(options.tgtPort).split(',')
2930

3031
if (tgtHost == None) | (tgtPorts[0] == None):
31-
print parser.usage
32+
print(parser.usage)
3233
exit(0)
3334

3435
for tgtPort in tgtPorts: # Scan the hosts with the ports etc

password_cracker.py

+5-4
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
from __future__ import print_function
12
# Script Name : password_cracker.py
23
# Author : Craig Richards
34
# Created : 20 May 2013
@@ -18,7 +19,7 @@
1819
try:
1920
import fcrypt # Try importing the fcrypt module
2021
except ImportError:
21-
print 'Please install fcrypt if you are on Windows'
22+
print('Please install fcrypt if you are on Windows')
2223

2324

2425
def testPass(cryptPass): # Start the function
@@ -28,9 +29,9 @@ def testPass(cryptPass): # Start the function
2829
word = word.strip('\n')
2930
cryptWord = crypt.crypt(word, salt) # Check for password in the file
3031
if (cryptWord == cryptPass):
31-
print "[+] Found Password: "+word+"\n"
32+
print("[+] Found Password: "+word+"\n")
3233
return
33-
print "[-] Password Not Found.\n"
34+
print("[-] Password Not Found.\n")
3435
return
3536

3637

@@ -40,7 +41,7 @@ def main():
4041
if ":" in line:
4142
user = line.split(':')[0]
4243
cryptPass = line.split(':')[1].strip(' ') # Prepare the user name etc
43-
print "[*] Cracking Password For: " + user
44+
print("[*] Cracking Password For: " + user)
4445
testPass(cryptPass) # Call it to crack the users password
4546

4647
if __name__ == "__main__":

ping_servers.py

+3-2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
from __future__ import print_function
12
# Script Name : ping_servers.py
23
# Author : Craig Richards
34
# Created : 9th May 2012
@@ -14,14 +15,14 @@
1415

1516
filename = sys.argv[0] # Sets a variable for the script name
1617
if '-h' in sys.argv or '--h' in sys.argv or '-help' in sys.argv or '--help' in sys.argv: # Help Menu if called
17-
print '''
18+
print('''
1819
You need to supply the application group for the servers you want to ping, i.e.
1920
dms
2021
swaps
2122
2223
Followed by the site i.e.
2324
155
24-
bromley'''
25+
bromley''')
2526
sys.exit(0)
2627
else:
2728

ping_subnet.py

+3-2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
from __future__ import print_function
12
# Script Name : ping_subnet.py
23
# Author : Craig Richards
34
# Created : 12th January 2012
@@ -15,8 +16,8 @@
1516
filename = sys.argv[0] # Sets a variable for the script name
1617

1718
if '-h' in sys.argv or '--h' in sys.argv or '-help' in sys.argv or '--help' in sys.argv: # Help Menu if called
18-
print '''
19-
You need to supply the first octets of the address Usage : ''' + filename + ''' 111.111.111 '''
19+
print('''
20+
You need to supply the first octets of the address Usage : ''' + filename + ''' 111.111.111 ''')
2021
sys.exit(0)
2122
else:
2223

portscanner.py

+8-7
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
from __future__ import print_function
12
# Script Name : portscanner.py
23
# Author : Craig Richards
34
# Created : 20 May 2013
@@ -21,11 +22,11 @@ def connScan(tgtHost, tgtPort): # Start of the function
2122
connSkt.send('')
2223
results=connSkt.recv(100)
2324
screenLock.acquire() # Acquire the lock
24-
print '[+] %d/tcp open'% tgtPort
25-
print '[+] ' + str(results)
25+
print('[+] %d/tcp open'% tgtPort)
26+
print('[+] ' + str(results))
2627
except:
2728
screenLock.acquire()
28-
print '[-] %d/tcp closed '% tgtPort
29+
print('[-] %d/tcp closed '% tgtPort)
2930
finally:
3031
screenLock.release()
3132
connSkt.close()
@@ -34,13 +35,13 @@ def portScan(tgtHost, tgtPorts): # Start of the function
3435
try:
3536
tgtIP = gethostbyname(tgtHost) # Get the IP from the hostname
3637
except:
37-
print "[-] Cannot resolve '%s': Unknown host"%tgtHost
38+
print("[-] Cannot resolve '%s': Unknown host"%tgtHost)
3839
return
3940
try:
4041
tgtName = gethostbyaddr(tgtIP) # Get hostname from IP
41-
print '\n[+] Scan Results for: ' +tgtName[0]
42+
print('\n[+] Scan Results for: ' +tgtName[0])
4243
except:
43-
print '\n[+] Scan Results for: ' + tgtIP
44+
print('\n[+] Scan Results for: ' + tgtIP)
4445
setdefaulttimeout(1)
4546
for tgtPort in tgtPorts: # Scan host and ports
4647
t = Thread(target=connScan, args=(tgtHost, int(tgtPort)))
@@ -54,7 +55,7 @@ def main():
5455
tgtHost = options.tgtHost
5556
tgtPorts = str(options.tgtPort).split(',')
5657
if (tgtHost == None) | (tgtPorts[0] == None):
57-
print parser.usage
58+
print(parser.usage)
5859
exit(0)
5960
portScan(tgtHost, tgtPorts)
6061
if __name__ == '__main__':

powerup_checks.py

+5-4
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
from __future__ import print_function
12
# Script Name : powerup_checks.py
23
# Author : Craig Richards
34
# Created : 25th June 2013
@@ -63,27 +64,27 @@ def get_servers(query): # Function to get the ser
6364
break
6465
f = open(serverfile, 'a') # Open the serverfile
6566
f.write("%s\n" % str(row[0])) # Write the server out to the file
66-
print row[0] # Display the server to the screen
67+
print(row[0]) # Display the server to the screen
6768
f.close() # Close the file
6869

6970
def main(): # Main Function
7071
if os.path.exists(serverfile): # Checks to see if there is an existing server file
7172
os.remove(serverfile) # If so remove it
7273

7374
if len(sys.argv) < 2: # Check there is an argument being passed
74-
print text # Display the help text if there isn't one passed
75+
print(text) # Display the help text if there isn't one passed
7576
sys.exit() # Exit the script
7677

7778
if '-h' in sys.argv or '--h' in sys.argv or '-help' in sys.argv or '--help' in sys.argv: # If the ask for help
78-
print text # Display the help text if there isn't one passed
79+
print(text) # Display the help text if there isn't one passed
7980
sys.exit(0) # Exit the script after displaying help
8081
else:
8182
if sys.argv[1].lower().startswith('-site1'): # If the argument is site1
8283
query = 'site1' # Set the variable to have the value site
8384
elif sys.argv[1].lower().startswith('-site2'): # Else if the variable is bromley
8485
query = 'site2' # Set the variable to have the value bromley
8586
else:
86-
print '\n[-] Unknown option [-] ' + text # If an unknown option is passed, let the user know
87+
print('\n[-] Unknown option [-] ' + text) # If an unknown option is passed, let the user know
8788
sys.exit(0)
8889
get_servers(query) # Call the get servers funtion, with the value from the argument
8990

pscheck.py

+12-9
Original file line numberDiff line numberDiff line change
@@ -8,32 +8,35 @@
88

99
# Description : Process check on Nix boxes, diplsay formatted output from ps command
1010

11-
import commands, os, string
11+
import commands
12+
import os
13+
import string
14+
1215

1316
def ps():
1417
program = raw_input("Enter the name of the program to check: ")
1518

1619
try:
17-
#perform a ps command and assign results to a list
20+
# perform a ps command and assign results to a list
1821
output = commands.getoutput("ps -f|grep " + program)
1922
proginfo = string.split(output)
2023

21-
#display results
22-
print "\n\
24+
# display results
25+
print("\n\
2326
Full path:\t\t", proginfo[5], "\n\
2427
Owner:\t\t\t", proginfo[0], "\n\
2528
Process ID:\t\t", proginfo[1], "\n\
2629
Parent process ID:\t", proginfo[2], "\n\
27-
Time started:\t\t", proginfo[4]
30+
Time started:\t\t", proginfo[4])
2831
except:
29-
print ("There was a problem with the program.")
32+
print("There was a problem with the program.")
3033

3134
def main():
3235
if os.name == "posix": # Unix/Linux/MacOS/BSD/etc
3336
ps() # Call the function
3437
elif os.name in ("nt", "dos", "ce"): # if the OS is windows
35-
print "You need to be on Linux or Unix to run this"
36-
37-
38+
print("You need to be on Linux or Unix to run this")
39+
40+
3841
if __name__ == '__main__':
3942
main()

psunotify.py

+7-4
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
from __future__ import print_function
12
import mechanize
23
import re
34
import urllib2
@@ -19,7 +20,9 @@
1920
urls[int]=urls[int].replace("<b>","")
2021
urls[int]=urls[int].replace("</b>","")
2122
int=int+1
22-
print (urls)
23+
24+
print(urls)
25+
2326
for url in urls:
2427
try:
2528
temp=url.split("/")
@@ -31,7 +34,7 @@
3134
file=open('psu2'+q+'.pdf','wb')
3235
file.write(r.read())
3336
file.close()
34-
print ("Done")
35-
except urllib2.URLError as e:
36-
print ("Sorry there exists a problem with this URL Please Download this Manually "+str(url))
3737

38+
print("Done")
39+
except urllib2.URLError as e:
40+
print("Sorry there exists a problem with this URL Please Download this Manually "+str(url))

python_sms.py

+8-6
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
from __future__ import print_function
12
# Script Name : python_sms.py
23
# Author : Craig Richards
34
# Created : 16th February 2017
@@ -63,14 +64,15 @@
6364
postdata = urllib.urlencode(values)
6465
req = urllib2.Request(url, postdata)
6566

66-
print ('Attempting to send SMS to '+ sname + ' at ' + snumber + ' on ' + tdate)
67-
f.write ('Attempting to send SMS to '+ sname + ' at ' + snumber + ' on ' + tdate + '\n')
67+
print('Attempting to send SMS to '+ sname + ' at ' + snumber + ' on ' + tdate)
68+
f.write('Attempting to send SMS to '+ sname + ' at ' + snumber + ' on ' + tdate + '\n')
6869

6970
try:
7071
response = urllib2.urlopen(req)
7172
response_url = response.geturl()
7273
if response_url == url:
73-
print ('SMS sent!')
74-
except urllib2.URLError, e:
75-
print ('Send failed!')
76-
print (e.reason)
74+
75+
print('SMS sent!')
76+
except urllib2.URLError as e:
77+
print('Send failed!')
78+
print(e.reason)

0 commit comments

Comments
 (0)