- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我在汇编中使用手动系统调用。我之前能够使其正常启动,但在删除空值后,我无法让系统调用执行 /bin/date
.这是我用 AT&T 语法编写的代码。
.global main
main:
jmp two
one:
# zero rax and rdx
xor %rax,%rax
mov %rax,%rdx
# save string location
mov (%rsp),%rbx
# push argv array onto the stack
add $16, %rsp
push %rax
push %rbx
# assign argv pointer
mov %rsp,%rcx
# execve call
mov $0xb, %al
int $0x80
# exit on failure
xor %rax,%rax
xor %rbx,%rbx
movb $0x1,%al
int $0x80
two:
# get address of the string
call one
.string "/bin/date"
%rbx
应该直接指向命名要启动的程序的字符串。
%rcx
应该指向一个以空结尾的指针数组,表示程序的
argv
, 和
%rdx
会指向环境,所以我把它留空了。当然,
%rax
保存系统调用号(在本例中为
0x0b
)。
(gdb) info registers
rax 0xb 11
rbx 0x4000a0 4194464
rcx 0x7fffffffe968 140737488349544
rdx 0x0 0
(gdb) x/s $rbx
0x4000a0: "/bin/date"
(gdb) x/s *$rcx
0x4000a0: "/bin/date"
EFAULT
。 (段错误)。我不确定我忽略了什么,任何帮助将不胜感激。
%ebx
、
int $0x80
和 friend )。这是一个错误,因为仅支持 32 位约定以启用执行 32 位代码。在为 64 位系统编写的代码中,系统调用使用
%rdi
,
%rsi
,
%rdx
,
%r10
,
%r8
和
%r9
以及
syscall
操作说明。这是 64 位系统的更正代码(nullfree):
.global main
main:
jmp two
one:
# zero rax and rdx
xor %rax,%rax
mov %rax,%rdx
# save string location, note that %rdi is used instead of %rbx
pop %rdi
# push argv array onto the stack
add $16, %rsp
push %rax
push %rdi
# assign argv pointer, using %rsi instead of %rcx
mov %rsp,%rsi
# execve call, note that the syscall number is different than in 32bit
mov $0x3b, %al
syscall
two:
# get address of the string
call one
.string "/bin/date"
execve
d 在此系统上使用 32 位调用约定的其他命令。事实上,我为 x86_64 系统检查的大部分“shellcode”都使用 32 位约定。所以,我的问题仍然存在:
为什么 32 位调用约定在上述代码中不起作用?
最佳答案
execve() 调用有原型(prototype)
int execve(const char *filename,
char *const argv[],
char *const envp[]);
NULL
通常不传递指针,但如果
envp[]
数组是空的,你应该传递一个指向 NULL 的指针,它作为环境变量的结尾。同样,
argv[]
不能是 NULL 指针。它必须至少包含
argv[0]
这是程序名称。通常放置
filename
就足够了作为第一个元素。为了完全符合 shell 的功能,剥离路径并仅将最后一个组件作为 argv[0] (在您的示例中为
date
)传递。
char *filename = "/bin/date";
char *argv [2] = {filename, NULL};
char *envp [1] = {NULL};
execve (filename, argv, envp);
char *filename = "/bin/date";
execve (filename, NULL); // note missing third parameter, and malformed argv[]
关于assembly - execve syscall 在 64 位 AMD 上使用 32 位调用约定返回 EFAULT,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10965793/
假设我有一个函数,例如 f(x,y)但y参数是可选的。设置y的首选方式是什么?作为可选参数?对我有用的一种选择: function f(x, y=nothing) # do stuff
在学习核心动画时,我很快就了解到,如果你做得不对,你会得到非常奇怪的未定义行为。为此,我有几个问题可以帮助我从概念上更好地理解它。 我的 NSView 子类在其 init.h 中声明以下内容:该 Vi
我一直在尝试学习 ClojureScript,并偶然发现了一些非常神秘的函数名称。 例如: (.-length str) 来自 om 文档: (defn add-contact [data owner
我对此很好奇。我最近想到使用大括号来隔离代码段,以进行可视化组织,并将变量隔离到特定范围(如果只是为了防止它们在较大的函数中混淆 Eclipse 中的建议)。例如: public void start
所以我进行了一些搜索,但在 Google 或 PEP 上找不到任何讨论此问题的内容。 我正在使用 tkinter 做一个项目,我有一个文件,它是项目的一部分,只有 200 行代码(不包括所有注释掉的代
根据某种不成文的约定,所有 API key 都是十六进制数字吗? 最佳答案 对一些半随机数据(例如时间戳 + 用户 ID + key )进行 md5 哈希是一种快速生成难以猜测的固定长度 key 的方
在 C 中,如果编译器想要提供实现定义的标识符(语言扩展、内在函数、伪函数和伪宏,基本上任何不是语言标准保留关键字但也不是常规函数的东西)惯例是名称以下划线为前缀;据了解,代码不应出于正常目的使用此类
Java Bean 的约定之一是: setter 的返回类型必须是 void。 或者至少大多数人是这么说的。我的问题是:它真的必须无效吗?我喜欢返回 "this" 而不是 "void" 因为我可以像这
我对 Java 编码风格有疑问。 我编码: public class Pattern { public Pattern(...) { ... } public static List
我有一个关于 Java servlet 约定的问题。在查看 servlet 的任何教程时,无论是 Eclipse、NetBeans 等,它们总是让您创建一个 index.jsp 页面。创建页面后,他们
在 python 中,当变量名与保留字冲突时(如 class、in、default 等),PEP8约定规定应使用尾随下划线(class_、in_、default_)。 对于相同的情况,共享最多的 ja
关闭。这个问题是opinion-based .它目前不接受答案。 想要改进这个问题? 更新问题,以便 editing this post 可以用事实和引用来回答它. 关闭 5 年前。 Improve
Java 存储预定义字符串集的主要约定是什么?现在我有一个包含我使用的所有字符串的类,但感觉确实有更好的方法来做到这一点。 这就是我在 my_strings.java 类中所做的 public fin
我经常需要检索结果并按给定列访问它们。 有没有一种方法可以不用每次都遍历整个数据集来编写它? 我研究了各种 PDO 获取模式,但没有发现比这更简单的模式。谢谢。 function get_groups
所以我正在制作这个 android 应用程序,它需要从用户提供的 CSV 文件中读取数据。 CSV 文件在台式电脑上编辑起来更舒服,所以我在应用程序中没有编辑器,它是“只读”的;我假设手机的 SD 卡
我正在编写一个文件,该文件是 npycurses module 的子类 npycurses.ActionFormV2 ,我正在覆盖 beforeEditing method ,所以当我整理我的文件时,
关闭。这个问题是opinion-based .它目前不接受答案。 想要改进这个问题? 更新问题,以便 editing this post 可以用事实和引用来回答它. 关闭 8 年前。 Improve
我正在开发一个可在 iPhone、iPad 和其他移动设备上运行的网页。我很好奇是否有关于移动设备 CSS 最佳实践的资源。 我试过搜索,但想出了随机网站 with tidbits of inform
我发现开始编程时最大的挑战之一是掌握文件路径。例如,当您引用目录结构中同一级别的文件夹中的路径时,您将看到: /folder/style.css 或 文件夹/style.css等 当您引用不同的文件时
如果我有如下函数: def foo(): return 1, 2 我通常会这样调用函数: g, f = foo() 但是,如果我从不打算使用返回的第二个值,是否有一种调用函数的方法可以明确说明
我是一名优秀的程序员,十分优秀!