Conversion héxadécimal > bytecode

Switch.

Codeur Web à ton service | > Python
Premium
Inscription
13 Janvier 2013
Messages
2 956
Réactions
968
Points
6 491
RGCoins
25
https://reality-gaming.fr/proxy.php?image=http%3A%2F%2Fiamswitch.fr%2Fipwc.png&hash=2e37a67a2baed63fb2bc556524b85af3
Bonsoir à tous , je voulais vous partager un petit script que j'ai écrit vite fait en python.
Il permet de convertir une chaine héxadécimale en bytecode (instruction directement éxécutable).

En gros il vous évite de mettre un "\x" entre chaque octet


Code:
#!/usr/bin/python3.4
import sys

string = sys.argv[1]
shellcode = []
shell = ["\\x"]

x = 0
for i in string:
    if i != " ":
        if i !="\n":
            shellcode.append(i)

while x < len(shellcode):
    shell.append(shellcode[x])
    if  x % 2 :
        if not x == 0:
            shell.append("\\x")
    x+= 1

if(shell[len(shell)-1] == " "):
    del shell[len(shell)-1]
if(shell[len(shell)-1] == "\\x"):
    del shell[len(shell)-1]

shell = "".join(shell)
print(shell)

copier le script et faite un cp /bin/tohex par exemple et passé lui votre chaine (sans oublier les "") en argument. Vous pouvez rediriger la sortie standard vers un fichier ou simplement fait un c/c

exemple d'utilisation

gorv.png

Cdlt switch
 
Y a plus simple que ça :

Code:
import binascii

string = sys.argv[1]

binString = binascii.a2b_hex(string) # hexadecimal -> bytes
binascii.hexlify(binString) # bytes -> hexadecimal
 
Y a plus simple que ça :

Code:
import binascii

string = sys.argv[1]

binString = binascii.a2b_hex(string) # hexadecimal -> bytes
binascii.hexlify(binString) # bytes -> hexadecimal
Connaissait pas mais j'prefere utiliser mes propres outils, ça fait pratiquer. Merci en tt cas
 
Retour
Haut