@@ -50,6 +50,8 @@ func guessBinary() string {
50
50
}
51
51
52
52
func makeScript (ip string , port int ) {
53
+ binary := guessBinary ()
54
+
53
55
script := fmt .Sprintf (
54
56
"#!/usr/bin/env python3\n \n " +
55
57
"#\n # pwn template made with 🚩 https://github.com/rerrorctf/rctf 🚩\n #\n \n " +
@@ -65,7 +67,7 @@ func makeScript(ip string, port int) {
65
67
"#gdb.attach(p, gdbscript=\" \" )\n \n " +
66
68
"# pwn it here\n \n " +
67
69
"p.interactive()\n " ,
68
- guessBinary () , ip , port )
70
+ binary , ip , port )
69
71
70
72
err := os .WriteFile (config .PwnScriptName , []byte (script ), 0644 )
71
73
if err != nil {
@@ -77,7 +79,41 @@ func makeScript(ip string, port int) {
77
79
log .Fatalln ("error chmoding file:" , err )
78
80
}
79
81
80
- fmt .Printf ("🐚 " + theme .ColorGray + "ready to pwn:" + theme .ColorReset + " $ ./%s\n " , config .PwnScriptName )
82
+ dockerfile := fmt .Sprintf (
83
+ "#\n # Dockerfile template made with 🚩 https://github.com/rerrorctf/rctf 🚩\n #\n \n " +
84
+ "FROM ubuntu:24.04\n \n " +
85
+ "RUN apt update && apt install -y socat\n \n " +
86
+ "RUN groupadd --gid 1001 pwn\n \n " +
87
+ "RUN useradd --uid 1001 --gid 1001 --home-dir /home/pwn --create-home --shell /sbin/nologin pwn\n \n " +
88
+ "WORKDIR /home/pwn\n \n " +
89
+ "COPY %s .\n \n " +
90
+ "COPY flag.txt .\n \n " +
91
+ "RUN chmod +x ./%s\n \n " +
92
+ "EXPOSE %d\n \n " +
93
+ "USER pwn\n \n " +
94
+ "CMD [\" socat\" , \" tcp-listen:%d,fork,reuseaddr\" , \" exec:./%s\" ]\n " ,
95
+ binary , binary , port , port , binary )
96
+
97
+ err = os .WriteFile ("Dockerfile" , []byte (dockerfile ), 0644 )
98
+ if err != nil {
99
+ log .Fatalln ("error writing to file:" , err )
100
+ }
101
+
102
+ compose := fmt .Sprintf (
103
+ "#\n # compose.yml template made with 🚩 https://github.com/rerrorctf/rctf 🚩\n #\n \n " +
104
+ "services:\n " +
105
+ " task:\n " +
106
+ " build: .\n " +
107
+ " ports:\n " +
108
+ " - %d:%d\n " ,
109
+ port , port )
110
+
111
+ err = os .WriteFile ("compose.yml" , []byte (compose ), 0644 )
112
+ if err != nil {
113
+ log .Fatalln ("error writing to file:" , err )
114
+ }
115
+
116
+ fmt .Printf ("🐚 " + theme .ColorGray + "ready to pwn:" + theme .ColorReset + " $ sudo docker compose up --build -d && ./%s\n " , config .PwnScriptName )
81
117
}
82
118
83
119
func Pwn (args []string ) {
@@ -95,6 +131,16 @@ func Pwn(args []string) {
95
131
log .Fatalf ("💥 " + theme .ColorRed + "error" + theme .ColorReset + ": \" %s\" already exists!\n " , config .PwnScriptName )
96
132
}
97
133
134
+ _ , err = os .Stat ("./Dockerfile" )
135
+ if ! os .IsNotExist (err ) {
136
+ log .Fatalf ("💥 " + theme .ColorRed + "error" + theme .ColorReset + ": \" Dockerfile\" already exists!\n " )
137
+ }
138
+
139
+ _ , err = os .Stat ("./compose.yml" )
140
+ if ! os .IsNotExist (err ) {
141
+ log .Fatalf ("💥 " + theme .ColorRed + "error" + theme .ColorReset + ": \" Dockerfile\" already exists!\n " )
142
+ }
143
+
98
144
var ip string
99
145
var port int
100
146
util .GetRemoteParams (args , & ip , & port )
0 commit comments