我正在学习缓冲区溢出漏洞利用.我写了这样一个易受攻击的程序:
#include <stdio.h>
#include <string.h>
main(int argc, char *argv[])
{
char buffer[80];
strcpy(buffer, argv[1]);
return 1;
}
Run Code Online (Sandbox Code Playgroud)
很简单的程序.想法是覆盖用于返回libc函数的返回地址start_main.一切都很顺利,我使用GDB来验证返回地址是否被指向shellcode内存中的正确地址覆盖.
但是,当我想要获得一个shell时,会出现:
Program received signal SIGSEGV, Segmentation fault. 0xbffff178 in ?? ()
0xbffff178是返回覆盖的返回地址,它确实指向shellcode我很确定.有帮助吗?
我正在编写一个将数据写入所选文件的简单程序.
除了换行符之外,一切都很顺利\n,字符串写在文件中但没有换行符
我试过了\n,\n\r但没有改变
程序:
public void prepare(){
String content = "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"no\"?>\n\r<data>\n\r<user><username>root</username><password>root</password></user>\n\r</data>";
FileOutputStream fos = null;
try {
fos = new FileOutputStream(file);
} catch (FileNotFoundException ex) {
System.out.println("File Not Found .. prepare()");
}
byte b[] = content.getBytes();
try {
fos.write(b);
fos.close();
} catch (IOException ex) {
System.out.println("IOException .. prepare()");
}
}
public static void main(String args[]){
File f = new File("D:\\test.xml");
Database data = new Database(f);
data.prepare();
}
Run Code Online (Sandbox Code Playgroud)