elhacker.net cabecera Bienvenido(a), Visitante. Por favor Ingresar o Registrarse
¿Perdiste tu email de activación?.

 

 


Tema destacado: Introducción a Git (Primera Parte)


+  Foro de elhacker.net
|-+  Programación
| |-+  Scripting
| | |-+  Problemas con scripts Python
0 Usuarios y 1 Visitante están viendo este tema.
Páginas: [1] Ir Abajo Respuesta Imprimir
Autor Tema: Problemas con scripts Python  (Leído 2,346 veces)
.:UND3R:.
Moderador Global
***
Desconectado Desconectado

Mensajes: 3.118


Ingeniería inversa / MASM


Ver Perfil WWW
Problemas con scripts Python
« en: 3 Julio 2013, 19:18 pm »

Hola a todos estoy teniendo dificultades con los scripts en mi sistema (Windows XP), me he descargado el instalador para windows 32bit y lo he instalado en Windows XP SP 2 en una máquina virtual, pero no logro ejecutar scripts, generalmente me marcan errores, ¿A qué se puede deber este inconveniente?, adjunto un script que me marca el siguiente error:

Citar
C:\Documents and Settings\Administrador\Escritorio\omelet>w32_SEH_omelet.py w32_
SEH_omelet.bin shellcode.bin hola.txt
  File "C:\Documents and Settings\Administrador\Escritorio\omelet\w32_SEH_omelet
.py", line 88
    """
      ^
SyntaxError: invalid syntax

Código
  1. import math
  2. import sys
  3.  
  4. def HexEncode(string):
  5.  result = ''
  6.  for char in string:
  7.    result += '\\x%02X' % ord(char)
  8.  return result
  9.  
  10. def Main(my_name, bin_file, shellcode_file, output_file, egg_size = '0x7F', marker_bytes = '0x280876'):
  11.  if (marker_bytes.startswith('0x')):
  12.    marker_bytes = int(marker_bytes[2:], 16)
  13.  else:
  14.    marker_bytes = int(marker_bytes)
  15.  if (egg_size.startswith('0x')):
  16.    egg_size = int(egg_size[2:], 16)
  17.  else:
  18.    egg_size = int(egg_size)
  19.  assert marker_bytes <= 0xFFFFFF, 'Marker must fit into 3 bytes.'
  20.  assert egg_size >= 6, 'Eggs cannot be less than 6 bytes.'
  21.  assert egg_size <= 0x7F, 'Eggs cannot be more than 0x7F (127) bytes.'
  22.  
  23.  bin = open(bin_file).read()
  24.  marker_bytes_location = ord(bin[-3])
  25.  max_index_location = ord(bin[-2])
  26.  egg_size_location = ord(bin[-1])
  27.  code = bin[:-3]
  28.  
  29.  shellcode = open(shellcode_file).read()
  30.  
  31.  max_index = int(math.ceil(len(shellcode) / (egg_size - 5.0)))
  32.  assert max_index <= 0xFF, ('The shellcode would require %X (%d) eggs of  %X '
  33.      '(%d) bytes, but 0xFF (255) is the maximum number of eggs.') % (
  34.      max_index, max_index, egg_size, egg_size)
  35.  
  36.  marker_bytes_string = ''
  37.  for i in range(0,3):
  38.    marker_bytes_string += chr(marker_bytes & 0xFF)
  39.    marker_bytes >>= 8
  40.  
  41.  max_index_string = chr(max_index)
  42.  egg_size_string = chr(egg_size - 5)
  43.  # insert variables into code
  44.  code = code[:marker_bytes_location] + marker_bytes_string + code[marker_bytes_location+3:]
  45.  code = code[:max_index_location] + max_index_string + code[max_index_location+1:]
  46.  code = code[:egg_size_location] + egg_size_string + code[egg_size_location+1:]
  47.  output = [
  48.    '// This is the binary code that needs to be executed to find the eggs, ',
  49.    '// recombine the orignal shellcode and execute it. It is %d bytes:' % (
  50.      len(code),),
  51.    'omelet_code = "%s";' % HexEncode(code),
  52.    '',
  53.    '// These are the eggs that need to be injected into the target process ',
  54.    '// for the omelet shellcode to be able to recreate the original shellcode',
  55.    '// (you can insert them as many times as you want, as long as each one is',
  56.    '// inserted at least once). They are %d bytes each:' % (egg_size,) ]
  57.  egg_index = 0
  58.  while shellcode:
  59.    egg = egg_size_string + chr(egg_index ^ 0xFF) + marker_bytes_string
  60.    egg += shellcode[:egg_size - 5]
  61.    if len(egg) < egg_size:
  62.      # tail end of shellcode is smaller than an egg: add pagging:
  63.      egg += '@' * (egg_size - len(egg))
  64.    output.append('egg%d = "%s";' % (egg_index, HexEncode(egg)))
  65.    shellcode = shellcode[egg_size - 5:]
  66.    egg_index += 1
  67.  open(output_file, 'w').write('\n'.join(output))
  68.  
  69. if __name__ == '__main__':
  70.  if len(sys.argv) == 1 or sys.argv[1] in ('-h', '-?', '/h', '/?'):
  71.    print """Syntax:
  72.    w32_SEH_omelet.py "omelet bin file" "shellcode bin file" "output txt file"
  73.        [egg size] [marker bytes]
  74.  
  75. Where:
  76.    omelet bin file = The omelet shellcode stage binary code followed by three
  77.                      bytes of the offsets of the "marker bytes", "max index"
  78.                      and "egg size" variables in the code.
  79.    shellcode bin file = The shellcode binary code you want to have stored in
  80.                      the eggs and reconstructed by the omelet shellcode stage
  81.                      code.
  82.    output txt file = The file you want the omelet egg-hunt code and the eggs
  83.                      to be written to (in text format).
  84.    egg size =        The size of each egg (legal values: 6-127, default: 127)
  85.    marker bytes =    The value you want to use as a marker to distinguish the
  86.                      eggs from other data in user-land address space (legal
  87.                      values: 0-0xFFFFFF, default value: 0x280876)
  88. """
  89.  assert len(sys.argv) >= 4 and len(sys.argv) <= 6, (
  90.      'Incorrect arguments; run "w32_SEH_omelet.py -?" for help.')
  91.  exit(Main(*sys.argv))

El script debería funcionar correctamente (estoy siguiendo un tutorial en donde se menciona, y no da problemas)

a ver si me ayudan, saludos.


En línea


Solicitudes de crack, keygen, serial solo a través de mensajes privados (PM)
Eleкtro
Ex-Staff
*
Desconectado Desconectado

Mensajes: 9.813



Ver Perfil
Re: Problemas con scripts Python
« Respuesta #1 en: 3 Julio 2013, 19:29 pm »

Funciona corréctamente, ¿Que version de python estás usando?, ¿Estás usando la misma version de PY que la del tutorial?...eso es muy importante.

Deja la linea conflictiva así a ver si se soluciona:
Código
  1. values: 0-0xFFFFFF, default value: 0x280876)"""

No sé como estará el tema de las comillas dobles en Python 3.0.

Saludos!


En línea

.:UND3R:.
Moderador Global
***
Desconectado Desconectado

Mensajes: 3.118


Ingeniería inversa / MASM


Ver Perfil WWW
Re: Problemas con scripts Python
« Respuesta #2 en: 3 Julio 2013, 22:21 pm »

Solucionado: El problema era la versión usé la 2.7x y me ha funcionado todo a perfección, saludos y gracias  ;-)
En línea


Solicitudes de crack, keygen, serial solo a través de mensajes privados (PM)
Páginas: [1] Ir Arriba Respuesta Imprimir 

Ir a:  

Mensajes similares
Asunto Iniciado por Respuestas Vistas Último mensaje
scripts python programados
Desarrollo Web
Kase 0 2,164 Último mensaje 15 Mayo 2011, 03:30 am
por Kase
[PAPER] Compilación de scripts en Python a .exe « 1 2 3 »
Scripting
WaAYa HaCK 20 12,848 Último mensaje 18 Enero 2013, 19:12 pm
por Eleкtro
scripts python en blogger
Desarrollo Web
flacc 2 2,124 Último mensaje 15 Diciembre 2012, 18:52 pm
por flacc
[AYUDA][PYTHON] los scripts que compilo a ejecutable con py2exe no me funcionan
Scripting
Noxware 4 3,731 Último mensaje 29 Enero 2014, 16:48 pm
por Noxware
Problemas independientes con Sesion(Prot DDOS) y con Challenge(Postear Scripts)
Sugerencias y dudas sobre el Foro
@XSStringManolo 0 1,813 Último mensaje 27 Octubre 2019, 21:00 pm
por @XSStringManolo
WAP2 - Aviso Legal - Powered by SMF 1.1.21 | SMF © 2006-2008, Simple Machines