|
1 |
| -# By Alphabug |
2 |
| -# Github https://github.com/AlphabugX/csOnvps |
3 |
| -mkdir Alphabug_CS |
4 |
| -cd Alphabug_CS |
5 |
| -Alphabug_CS_PATH=`pwd` |
6 |
| -function radom_key(){ |
7 |
| - KEY=`uuid | md5sum |awk -F' ' '{ print $1}'` |
8 |
| - echo $KEY |
9 |
| -} |
10 | 1 |
|
11 |
| -sudo apt update && sudo apt install unrar uuid -y |
12 |
| -if ((`curl https://github.com --connect-timeout 5 -m 5 -s | wc -l` > 10)) ; then |
13 |
| - echo "[+] Welcome to Github Script..." |
14 |
| - wget -L https://github.com/AlphabugX/csOnvps/releases/download/jdk-8u202-linux-x64/jdk-8u202-linux-x64.tar.gz |
15 |
| - wget -c https://github.com/k8gege/Aggressor/releases/download/cs/K8_CS_4.4_20211109.rar |
16 |
| - wget -L https://raw.githubusercontent.com/AlphabugX/csOnvps/main/teamserver |
17 |
| -else |
18 |
| - echo "[+] Welcome to Gitee Script..." |
19 |
| - wget -L https://gitee.com/Alphabug/csOnvps/attach_files/900305/download/jdk-8u202-linux-x64.tar.gz_part_aa |
20 |
| - wget -L https://gitee.com/Alphabug/csOnvps/attach_files/900305/download/jdk-8u202-linux-x64.tar.gz_part_ab |
21 |
| - wget -L https://gitee.com/Alphabug/csOnvps/attach_files/900361/download/K8_CS_4.4_20211109.rar |
22 |
| - cat jdk-8u202-linux-x64.tar.gz_part_* > jdk-8u202-linux-x64.tar.gz |
23 |
| - wget -L https://gitee.com/Alphabug/csOnvps/raw/master/teamserver |
24 |
| -fi |
| 2 | +#!/bin/bash |
| 3 | +# |
| 4 | +# Start Cobalt Strike Team Server |
| 5 | +# |
| 6 | + |
| 7 | +touch TeamServer.prop |
25 | 8 |
|
26 |
| -tar xf jdk-8u202-linux-x64.tar.gz |
27 |
| -mv jdk1.8.0* jdk1.8.0 |
28 |
| -ln -s `pwd`/jdk1.8.0/bin/* /usr/bin/ |
29 |
| -unrar x K8_CS_4.4_20211109.rar -pk8gege.org |
30 |
| -rm -rf *.tar* |
31 |
| -# 改K8 CS的默认配置,改成随机 |
| 9 | +TEAMSERVER_PORT="SET_TEAMSERVER_PORT" |
| 10 | +TEAMSERVER_KEY="SET_TEAMSERVER_KEY" |
| 11 | +rm -rf cobaltstrike.store |
32 | 12 |
|
33 |
| -IP=`curl ip.0xc2.cn` |
34 |
| -PASSWORD=`radom_key` |
35 |
| -KEYPASS=`radom_key` |
36 |
| -cd K8_CS_4.4/ |
37 |
| -mv ../teamserver . |
38 |
| -chmod 777 * |
39 | 13 |
|
40 |
| -PORT=0 |
41 |
| -#判断当前端口是否被占用,没被占用返回0,反之1 |
42 |
| -function Listening { |
43 |
| - TCPListeningnum=`netstat -an | grep ":$1 " | awk '$1 == "tcp" && $NF == "LISTEN" {print $0}' | wc -l` |
44 |
| - UDPListeningnum=`netstat -an | grep ":$1 " | awk '$1 == "udp" && $NF == "0.0.0.0:*" {print $0}' | wc -l` |
45 |
| - (( Listeningnum = TCPListeningnum + UDPListeningnum )) |
46 |
| - if [ $Listeningnum == 0 ]; then |
47 |
| - echo "0" |
48 |
| - else |
49 |
| - echo "1" |
50 |
| - fi |
| 14 | +# make pretty looking messages (thanks Carlos) |
| 15 | +function print_good () { |
| 16 | + echo -e "\x1B[01;32m[+]\x1B[0m $1" |
51 | 17 | }
|
52 | 18 |
|
53 |
| -function get_random_port { |
54 |
| - templ=0 |
55 |
| - while [ $PORT == 0 ]; do |
56 |
| - temp1=`shuf -i $1-$2 -n1` |
57 |
| - if [ `Listening $temp1` == 0 ] ; then |
58 |
| - PORT=$temp1 |
59 |
| - fi |
60 |
| - done |
| 19 | +function print_error () { |
| 20 | + echo -e "\x1B[01;31m[-]\x1B[0m $1" |
61 | 21 | }
|
62 |
| -get_random_port 10000 65534; |
63 | 22 |
|
64 |
| -# 配置teamserver |
65 |
| -sed -i 's/SET_TEAMSERVER_PORT/$PORT/g' teamserver |
66 |
| -sed -i 's/SET_TEAMSERVER_KEY/$KEYPASS/g' teamserver |
67 |
| -install_log="$Alphabug_CS_PATH/install.log" |
68 |
| -echo "[+] Teamserver IP:" $IP >> $install_log |
69 |
| -echo "[+] Teamserver Port:" $PORT >> $install_log |
70 |
| -echo "[+] Teamserver Password:" $PASSWORD >> $install_log |
71 |
| -echo "[+] Teamserver keyStorePassword:" $KEYPASS >> $install_log |
72 |
| -nohup ./teamserver $IP $PASSWORD & |
73 |
| -PID=`sudo ps -ef | grep $PASSWORD |awk -F" " '{ print $2 }' |tr "\n" " "` >> $install_log |
74 |
| -echo "[+] Teamserver PID:" $PID >> $install_log |
75 |
| -echo "[*] Teamserver stop Command: kill -KILL " $PID >> $install_log |
76 |
| -echo "[!] Remove Sun JDK Command:" >> $install_log |
77 |
| -echo Zm9yIGl0ZW0gaW4gYGxzIC1sc2EgL3Vzci9iaW4vIHxncmVwIGpkayB8YXdrIC1GIiAiICd7IHByaW50ICQxMH0nYDsgZG8gZWNobyAiRGVsIC91c3IvYmluLyIkaXRlbTtybSAtcmYgIi91c3IvYmluLyIkaXRlbTtkb25lCg== | base64 -d >> $install_log |
78 |
| -echo "[!] Remove Alphabug_CS Command: rm -rf "$Alphabug_CS_PATH >> $install_log |
79 |
| -cat $install_log |
80 |
| -echo "[+] Saved to file:" $install_log |
| 23 | +function print_info () { |
| 24 | + echo -e "\x1B[01;34m[*]\x1B[0m $1" |
| 25 | +} |
| 26 | + |
| 27 | +# check that we're r00t |
| 28 | +if [ $UID -ne 0 ]; then |
| 29 | + print_error "Superuser privileges are required to run the team server" |
| 30 | + exit |
| 31 | +fi |
| 32 | + |
| 33 | +# check if java is available... |
| 34 | +if [ $(command -v java) ]; then |
| 35 | + true |
| 36 | +else |
| 37 | + print_error "java is not in \$PATH" |
| 38 | + echo " is Java installed?" |
| 39 | + exit |
| 40 | +fi |
| 41 | + |
| 42 | +# check if keytool is available... |
| 43 | +if [ $(command -v keytool) ]; then |
| 44 | + true |
| 45 | +else |
| 46 | + print_error "keytool is not in \$PATH" |
| 47 | + echo " install the Java Developer Kit" |
| 48 | + exit |
| 49 | +fi |
| 50 | + |
| 51 | +# generate a certificate |
| 52 | + # naturally you're welcome to replace this step with your own permanent certificate. |
| 53 | + # just make sure you pass -Djavax.net.ssl.keyStore="/path/to/whatever" and |
| 54 | + # -Djavax.net.ssl.keyStorePassword="password" to java. This is used for setting up |
| 55 | + # an SSL server socket. Also, the SHA-1 digest of the first certificate in the store |
| 56 | + # is printed so users may have a chance to verify they're not being owned. |
| 57 | +if [ -e ./cobaltstrike.store ]; then |
| 58 | + print_info "Will use existing X509 certificate and keystore (for SSL)" |
| 59 | +else |
| 60 | + print_info "Generating X509 certificate and keystore (for SSL)" |
| 61 | + keytool -keystore ./cobaltstrike.store -storepass $TEAMSERVER_KEY -keypass $TEAMSERVER_KEY -genkey -keyalg RSA -alias cobaltstrike -dname "CN=*.microsoft.com, OU=Microsoft Corporation, O=Microsoft Corporation, L=Redmond, S=WA, C=US" |
| 62 | +fi |
| 63 | +echo |
| 64 | +# start the team server. |
| 65 | +java -XX:ParallelGCThreads=4 -Dcobaltstrike.server_port=$TEAMSEVER_PORT -Dcobaltstrike.server_bindto=0.0.0.0 -Djavax.net.ssl.keyStore=./cobaltstrike.store -Djavax.net.ssl.keyStorePassword=$TEAMSERVER_KEY -server -XX:+AggressiveHeap -XX:+UseParallelGC -classpath ./cobaltstrike.jar -javaagent:hook.jar=5e98194a01c6b48fa582a6a9fcbb92d6 -Duser.language=en server.TeamServer $* |
0 commit comments