简体   繁体   English

将参数char作为ASCII代码获取

[英]Get argument char as ASCII code

I'm working on my school project "ROP on ARM vs x86" 我正在做我的学校项目“ ARM vs x86上的ROP”

i've done my work on x86 and trying 'ret2zp' on ARM right now and i need help. 我已经在x86上完成了工作,现在正在ARM上尝试“ ret2zp”,我需要帮助。

please help such a linux newbie. 请帮助这样的Linux新手。


I'm following easy and neat example on ARM 'A Short Guid on ARM Exploitation' by Kumar & Gupta 我在跟随Kumar&Gupta撰写的关于ARM“关于ARM开发的简短指南”的简单明了的示例

On page 41, (my reputation is lack to post img..sorry) 在第41页上,(我的声誉不足,无法发布img..sorry)

there is a line 有一条线
(gdb) r 'printf "AAAABBBBCCCCDDDD\\x38\\x84" (gdb)r'printf“ AAAABBBBCCCCDDDD \\ x38 \\ x84”

so Kumar & Gupta was trying to put char array AAAABBBBCCCCDDDD&„ (with extended ascii code. nothing on simple ascii code) 因此Kumar&Gupta尝试将char数组AAAABBBBCCCCDDDD&„(具有扩展的ascii代码。简单的ascii代码上没有任何内容)

and i can't put my char array on argument for my code with 'printf' command; 而且我无法使用'printf'命令将char数组放在代码的参数上;

here's my simple code to use 'printf'. 这是我使用“ printf”的简单代码。

buffer_overflow.c buffer_overflow.c

#include <stdio.h>
#include <stdlib.h>

void IShouldNeverBeCalled(){
    puts("I should never be called");
    exit(0);
}

void Vulnerable(char *arg){
    char buff[10];
    strcpy(buff, arg);
}

int main(int argc, char **argv){
    Vulnerable(argv[1]);
    puts(argv[1]);
    return(0);
}

and it works as 它作为

root@linaro:~# ./buffer_overflow AAAABBBB
AAAABBBB

root@linaro:~# ./buffer_overflow 'printf "A"' 
printf "A"

so printf isn't working as i expected. 所以printf不能按我预期的那样工作。

how can i use 'printf' as Kumar & Gupta said so?? 我如何使用Kumar&Gupta所说的'printf'?

how can my program get argument "A" when i put "'printf "\\x41"'"? 当我放入“'printf” \\ x41“'”时,程序如何获得参数“ A”?

and what is that printf? 那是什么printf? is it function on python something? 它在python上起作用吗? or is it program integrated with ubuntu? 还是它与ubuntu集成了程序?

oh my ubuntu is 哦,我的Ubuntu是

root@linaro:~# cat /etc/issue
Ubuntu natty (development branch) \n \l

thank you for helping me . 感谢你们对我的帮助 。

You're using apostrophe ' instead of backtick ` . 您使用的是撇号'而不是反引号` Additionally, the doc is missing the terminating backtick. 此外,该文档缺少终止反引号。

Instead of using backticks, though, you should use the better $() and quote properly: 但是,不要使用反引号,而应使用更好的$()并正确引用:

./buffer_overflow "$(printf "AAAABBBBCCCCDDDD\x38\x84")"

Also note that they're doing this in gdb, not in a shell. 还要注意,他们是在gdb中而不是在shell中执行此操作。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM