Advertisement
Guest User

Untitled

a guest
Feb 21st, 2019
77
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.51 KB | None | 0 0
  1. # regex for "nmap --script smb-enum-shares.nse -p445 <host>"
  2.  
  3. import subprocess as sb
  4. import sqlite3
  5. import re
  6. import nmap
  7.  
  8.  
  9.  
  10. # def callback_result(host, scan_result):
  11. # print('------------------')
  12. # print(host, scan_result)
  13. # ipAddr = '192.168.230.136'
  14. nma = nmap.PortScanner()
  15. dict_result = nma.scan(hosts='192.168.230.136', arguments='--script smb-enum-shares.nse -p445')
  16. # print nma.get_nmap_last_output()
  17. # print nma.analyse_nmap_xml_scan()
  18.  
  19. print dict_result
  20. print '\n\n'
  21. import pprint
  22. res = pprint.pprint(dict_result,depth=3)
  23. print res
  24.  
  25.  
  26.  
  27.  
  28. # print nma.command_line()
  29. # print nma.scaninfo()
  30. # print (nma.csv())
  31. # while nma.still_scanning():
  32. # print("Waiting ...")
  33. # nma.wait(4)
  34.  
  35.  
  36.  
  37. '''
  38. nm = nmap.PortScanner()
  39. nm.scan(hosts='192.168.230.136', arguments='-script smb-enum-shares.nse -p445')
  40. print '\ncommand_line' + str(nm.command_line() )
  41. print '\nscaninfo' + str(nm.scaninfo() )
  42. print '\ncsv' + str((nm.csv()))
  43. print nm.get_nmap_last_output()
  44. '''
  45.  
  46.  
  47. #print dir(nmap)
  48.  
  49.  
  50.  
  51.  
  52.  
  53.  
  54. # change the database name later on
  55. # con = sqlite3.connect(':memory:')
  56.  
  57. ipAddr = '192.168.230.136'
  58. # result = sb.check_output('nmap --script smb-enum-shares.nse -p445 %s'%(ipAddr),shell=True)
  59. # print result
  60.  
  61. smb_enum_shares_table = '''
  62. CREATE TABLE if not exists (
  63. id INTEGER PRIMARY KEY AUTOINCREMENT,
  64. timing TEXT DEFAULT (datetime('now','localtime')),
  65. ip_addr TEXT NOT NULL,
  66. share_folder TEXT NOT NULL,
  67.  
  68. );
  69. '''
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement