Advertisement
Guest User

MySQL data exfiltration

a guest
Dec 5th, 2016
308
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.60 KB | None | 0 0
  1. #!/usr/bin/python
  2.  
  3. import MySQLdb as dbapi #MUST INTALL THE APT DEPENDENCY (sudo apt-get install python-mysqldb)
  4. import sys
  5. import csv
  6.  
  7. dbServer='localhost' #SET HOST
  8. dbPass='supersecretpassword' #PASSWORD
  9. dbSchema='dbTest' #NAME OF THE DATABASE
  10. dbUser='root' #USERNAME
  11.  
  12. dbQuery='SELECT * FROM pbTest.Orders;' #SET DATA TO EXFILTRATE
  13.  
  14. db=dbapi.connect(host=dbServer,user=dbUser,passwd=dbPass) #INIT CONNECTION
  15. cur=db.cursor()
  16. cur.execute(dbQuery)
  17. result=cur.fetchall()
  18.  
  19. c = csv.writer(open("ChangeMe.csv","wb")) #SET CSV FILE AND ITERATE THROUGH RESULTS
  20. for row in result:
  21.     c.writerow(row)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement