【问题标题】:Python cannot find substring that I can see in EIP overflowPython 找不到我可以在 EIP 溢出中看到的子字符串
【发布时间】:2019-04-12 18:13:04
【问题描述】:

我有一个脚本用于自动化和理解应用程序模糊测试。 我正在运行 vulnserver 并进行模糊测试以找到堆栈溢出的点,然后生成一个唯一的字符串,然后再次发送该字符串以定位 EIP 被覆盖的点。

我遇到的问题是,我已经确定在发送As 的初始集合 2100 时发生溢出。从那里我使用下面的脚本生成一串连续字符,摘录...

Aa0Aa1Aa2Aa3Aa4Aa5Aa6Aa7Aa8Aa9Ab0Ab1Ab2

问题是当EIP被下面的覆盖时,我无法在生成的模式中找到EIP字符串

正在寻找字符串...

pattern.find(eip_string) 

EIP asciie 值:8qC7

在 IDLE 中运行时,我可以看到它找到了现有的字符串,但返回 -1 对于那些它无法找到/不存在的字符串。

str.find('Aa0')
0
str.find('8qC7')
-1
str.find('foo bar')
-1

问题是我如何生成字符串还是 Python 机制的其他问题? 我该如何解决这个问题,以便在主字符串中找到 EIP 模式?

方法生成模式... 链接到Github上的项目/方法

def create_pattern(self, length):
    index_up, index_down, int_index = 0, 0, 0

    int_list = list(range(0, 10))
    int_limit = len(int_list)-1 # 9

    char_list = string.ascii_lowercase
    char_limit = len(char_list)-1 # 25

    pattern = ''

while len(pattern) < length:
    if int_index <= int_limit:
        new_sequence = char_list[index_up].capitalize() + char_list[index_down] + str(int_list[int_index])
        pattern = pattern + new_sequence
        int_index += 1

    else:
        int_index = 0

        if index_down <= char_limit:
            index_down += 1

        if index_down >= char_limit:
            index_down = 0
            index_up += 1

        if index_up > char_limit:
            index_up = 0

self.pattern = pattern
return pattern

问题摘要

  1. 我生成了一个长的非连续字符串。
  2. 我已经使用主字符串的子字符串覆盖了 EIP,并且可以在调试器中看到它
  3. 搜索时,在主字符串中找不到子字符串

【问题讨论】:

  • 那么到底是什么问题,目前还不清楚。
  • @l'L'l 我可以看到写入 EIp 的子字符串在最初生成的字符串中似乎不存在
  • 您如何将子字符串放入EIP?如果您复制了它,我想它必须在原始字符串中。
  • @l'l 好吧,这就是我的想法!我不明白为什么不是
  • 在您的示例中,我认为永远找不到 8qC7,它必须是 8qC9,因为您的数字始终是连续的。也许再举一个例子,说明你正在采取什么并将其放入EIP,然后搜索...

标签: python-3.x security buffer-overflow


【解决方案1】:

所以我弄清楚了问题所在。显然 EIP 值是小端的。因此,我所要做的就是反转生成的字符串,这就解决了我的问题。

基本PICNIC 错误!

>> s = bytearray.fromhex(eip_query).decode()
>> s
'8oC7'
>> s[::-1]
'7Co8'
>> pattern.find_offset(s[::-1])
1943

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2011-03-14
    • 1970-01-01
    • 2018-06-26
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2011-09-05
    相关资源
    最近更新 更多