我最近在Linux中尝试了共享库注入,并决定编写自己的程序来实现它(而不是使用GDB来注入库).
我的程序使用pthread覆盖加载的程序程序的第一个0x25字节(0x40000-0x400025),用汇编代码为文件名分配空间并调用dlopen.完成所有这些后,它将恢复程序状态并从中分离.
这是集会:
global inject_library
global nullsub
section .data
section .text
inject_library:
; rdi -> Pointer to malloc()
; rsi -> Pointer to free()
; rdx -> Pointer to dlopen()
; rcx -> Size of the path to the .so to load
; Create a new stack frame
push rbp
; Save rbx because we're using it as scratch space
push rbx
; Save addresses of free & dlopen on the stack
push rsi
push rdx
; Move the pointer …
Run Code Online (Sandbox Code Playgroud) 我正在尝试使用 LLVM C++ 绑定来编写生成以下 IR 的传递
%1 = call i64 @time(i64* null) #3
Run Code Online (Sandbox Code Playgroud)
@time
这是 C 标准库time()
函数。
这是我写的代码
void Pass::Insert(BasicBlock *bb, Type *timety, Module *m) {
Type *timetype[1];
timetype[0] = timety;
ArrayRef<Type *> timeTypeAref(timetype, 1);
Value *args[1];
args[0] = ConstantInt::get(timety, 0, false);
ArrayRef<Value *> argsRef(args, 1);
FunctionType *signature = FunctionType::get(timety, false);
Function *timeFunc =
Function::Create(signature, Function::ExternalLinkage, "time", m);
IRBuilder<> Builder(&*(bb->getFirstInsertionPt()));
AllocaInst *a1 = Builder.CreateAlloca(timety, nullptr, Twine("a1"));
CallInst *c1 = Builder.CreateCall(timeFunc, args, Twine("time"));
}
Run Code Online (Sandbox Code Playgroud)
这编译,但运行时导致以下错误
Incorrect number of arguments …
Run Code Online (Sandbox Code Playgroud) 我在javascript中编写了一个函数,将整数形式的颜色从db转换为十六进制颜色格式.但是我无法将十六进制颜色字符串转换为int形式.另外,parseInt(color.substr(1),16)给出了不同的结果.
<html>
<body>
<button onclick="myFunction()">Try it</button>
<p id="test"></p>
<script>
function myFunction() {
var color="#ff0000";
var num = -65536;
var alphalessHexString =getHexColor(num);
var n = alphalessHexString+"</br>";
var ques="i want a function to convert "+color +" to "+num;
document.getElementById("test").innerHTML = n+ques;
}
function getHexColor(number){
return "#"+((number)>>>0).toString(16).slice(-6);
}
</script>
</body>
</html>
Run Code Online (Sandbox Code Playgroud)