Python Forum
Python bytecode: 64 bit parameter to LOAD_CONST
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Python bytecode: 64 bit parameter to LOAD_CONST
#1
I am trying to exploit an old python bug in a 64 bit environment.

In order to do that, I need to pass a 64 bit argument with LOAD_CONST. The problem is that LOAD_COST only accepts 2 byte argument,
I can extend that to 4 byte with the EXTENDED_ARG opcode, but I need 8 bytes, not 4.
Is there a way to do that?

This is my code so far:
#!/usr/bin/env python
# -*- coding: utf-8 -*-

import opcode
import types

def a():
  pass

const_tuple = ()
addr_const_tuple = id(const_tuple)
print 'addr_const_tuple: ' + hex(addr_const_tuple)

a.func_code = types.CodeType(
  0, 0, 0, 0,
  #chr(opcode.opmap['EXTENDED_ARG']) + '\xaa\xbb' +
  chr(opcode.opmap['EXTENDED_ARG']) + '\xad\xde' +
  chr(opcode.opmap['LOAD_CONST'])   + '\xef\xbe',
  const_tuple, (), (), '', '', 0, ''
)
a()
Adding multiple EXTENDED_ARG does not work.
Thank you!
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  How do I handle escape character in parameter arguments in Python? JKR 6 1,037 Sep-12-2023, 03:00 AM
Last Post: Apoed2023
  [ERROR] ParamValidationError: Parameter validation failed: Invalid type for parameter gdbengo 3 10,643 Dec-26-2022, 08:48 AM
Last Post: ibreeden
  python call stored procedure with two parameter mg24 4 1,402 Sep-27-2022, 05:02 AM
Last Post: deanhystad
  Hi Guys, please help me to write SAS macro parameter equivalent code in Python Manohar9589 2 2,537 Jun-14-2020, 05:07 PM
Last Post: Larz60+
  I need my compiled Python Mac app to accept a file as a parameter Oethen 2 2,357 May-10-2020, 05:57 PM
Last Post: Oethen
  Python Parameter inside Json file treated as String dhiliptcs 0 1,816 Dec-10-2019, 07:28 PM
Last Post: dhiliptcs

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020