Interact.sh
A pure python implementation of ProjectDiscovery's interact.sh.
"Interactsh is an open-source tool for detecting out-of-band interactions. It is a tool designed to detect vulnerabilities that cause external interactions."
- https://app.interactsh.com
- https://github.com/projectdiscovery/interactsh
This class facilitates interactions with the interact.sh service for
out-of-band data exfiltration and vulnerability confirmation. It allows
for customization by accepting server and token parameters from the
configuration provided by parent_helper
.
Attributes:
-
parent_helper
(ConfigAwareHelper
) –An instance of a helper class containing configuration data.
-
server
(str
) –The server to be used. If None (the default), a random server will be chosen from a predetermined list.
-
correlation_id
(str
) –An identifier to correlate requests and responses. Default is None.
-
custom_server
(str
) –Optional. A custom interact.sh server. Loaded from configuration.
-
token
(str
) –Optional. A token for interact.sh API. Loaded from configuration.
-
_poll_task
(AsyncTask
) –The task responsible for polling the interact.sh server.
Examples:
# instantiate interact.sh client (no requests are sent yet)
>>> interactsh_client = self.helpers.interactsh()
# register with an interact.sh server
>>> interactsh_domain = await interactsh_client.register()
[INFO] Registering with interact.sh server: oast.me
[INFO] Successfully registered to interactsh server oast.me with correlation_id rg99x2f860h5466ou3so [rg99x2f860h5466ou3so86i07n1m3013k.oast.me]
# simulate an out-of-band interaction
>>> await self.helpers.request(f"https://{interactsh_domain}/test")
# wait for out-of-band interaction to be registered
>>> await asyncio.sleep(10)
>>> data_list = await interactsh_client.poll()
>>> print(data_list)
[
{
"protocol": "dns",
"unique-id": "rg99x2f860h5466ou3so86i07n1m3013k",
"full-id": "rg99x2f860h5466ou3so86i07n1m3013k",
"q-type": "A",
"raw-request": "...",
"remote-address": "1.2.3.4",
"timestamp": "2023-09-15T21:09:23.187226851Z"
},
{
"protocol": "http",
"unique-id": "rg99x2f860h5466ou3so86i07n1m3013k",
"full-id": "rg99x2f860h5466ou3so86i07n1m3013k",
"raw-request": "GET /test HTTP/1.1 ...",
"remote-address": "1.2.3.4",
"timestamp": "2023-09-15T21:09:24.155677967Z"
}
]
# finally, shut down the client
>>> await interactsh_client.deregister()
Source code in bbot/core/helpers/interactsh.py
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 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 |
|
deregister
async
deregister()
Deregisters the instance from the interact.sh server and cancels the polling task.
Sends a POST request to the server to deregister, using the correlation ID and secret key generated during registration. Optionally, if a polling task was started, it is cancelled.
Raises:
-
InteractshError
–If required information is missing or if deregistration fails.
Examples:
>>> await interactsh_client.deregister()
Source code in bbot/core/helpers/interactsh.py
169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 |
|
poll
async
poll()
Polls the interact.sh server for interactions tied to the current instance.
Sends a GET request to the server to fetch interactions associated with the current correlation_id and secret key. Returned interactions are decrypted using an AES key provided by the server response.
Raises:
-
InteractshError
–If required information for polling is missing.
Returns:
-
list
–A list of decrypted interaction data dictionaries.
Examples:
>>> data_list = await interactsh_client.poll()
>>> print(data_list)
[
{
"protocol": "dns",
"unique-id": "rg99x2f860h5466ou3so86i07n1m3013k",
...
},
...
]
Source code in bbot/core/helpers/interactsh.py
202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 |
|
poll_loop
async
poll_loop(callback)
Starts a polling loop to continuously check for interactions with the interact.sh server.
Continuously polls the interact.sh server for interactions tied to the current instance,
using the poll
method. When interactions are received, it executes the given callback
function with each interaction data.
Parameters:
-
callback
(callable
) –The function to be called for every interaction received from the server.
Returns:
-
awaitable
–An awaitable object that executes the internal
_poll_loop
method.
Examples:
>>> await interactsh_client.poll_loop(my_callback)
Source code in bbot/core/helpers/interactsh.py
254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 |
|
register
async
register(callback=None)
Registers the instance with an interact.sh server and sets up polling.
Generates RSA keys for secure communication, builds a correlation ID, and sends a POST request to an interact.sh server to register. Optionally, starts an asynchronous polling task to listen for interactions.
Parameters:
-
callback
(callable
, default:None
) –A function to be called each time new interactions are received.
Returns:
-
str
–The registered domain for out-of-band interactions.
Raises:
-
InteractshError
–If registration with an interact.sh server fails.
Examples:
>>> interactsh_client = self.helpers.interactsh()
>>> registered_domain = await interactsh_client.register()
[INFO] Registering with interact.sh server: oast.me
[INFO] Successfully registered to interactsh server oast.me with correlation_id rg99x2f860h5466ou3so [rg99x2f860h5466ou3so86i07n1m3013k.oast.me]
Source code in bbot/core/helpers/interactsh.py
90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 |
|