일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | 2 | 3 | 4 | 5 | 6 | 7 |
8 | 9 | 10 | 11 | 12 | 13 | 14 |
15 | 16 | 17 | 18 | 19 | 20 | 21 |
22 | 23 | 24 | 25 | 26 | 27 | 28 |
29 | 30 |
- LLVM
- 안티디버깅
- apm
- pinpoint
- Android
- Linux packer
- linux thread
- pthread
- TLS
- tracerpid
- on stack replacement
- thread local storage
- android inject
- linux debugging
- tracing
- Obfuscator
- Injection
- Linux custom packer
- OSR
- so inject
- LLVM Obfuscator
- 난독화
- initial-exec
- v8 tracing
- custom packer
- uftrace
- LLVM 난독화
- v8 optimizing
- on-stack replacement
- anti debugging
- Today
- Total
목록분류 전체보기 (142)
Why should I know this?
LLVM Optimizing 과정을 공부하면서 효율을 높히고 기록을 남기기 위해서 고민을 좀 해봤습니다. 예로 들려는 최적화는 LoopFlatten 입니다. llvm/lib/Transforms/Scalar/LoopFlatten.cpp 에 구현되어 있습니다. 첫 번째, 최적화 과정에서 활용되는 로직을 모은 실행파일 견본으로 모아보려고 합니다. LoopFlatten에서 큰 비중을 차지하는 static bool findLoopComponents 함수에는 다음과 같은 내용이 있습니다. static bool findLoopComponents( Loop *L, SmallPtrSetImpl &IterationInstructions, PHINode *&InductionPHI, Value *&TripCount, Bina..

Loop에서 Latch란 다음과 같이 정의되어 있다. https://llvm.org/docs/LoopTerminology.html LLVM Loop Terminology (and Canonical Forms) — LLVM 17.0.0git documentation The Loop Simplify Form is a canonical form that makes several analyses and transformations simpler and more effective. It is ensured by the LoopSimplify (-loop-simplify) pass and is automatically added by the pass managers when scheduling a LoopPass...

LoopFlatten은 Loop 문을 평탄화 하는 최적화인데, 말로는 느낌이 잘 안오니 다음 주석을 참고하자. LoopFlatten.cpp // for (int i = 0; i
개발자들은 주로 주석을 통해 많은 정보를 코드에 덧붙여놓는데 자체 Trace 코드를 추가하면 장점이 있습니다. 1. 복기에 좋다. 2. 유지보수에 좋다. 3. 후임자에게 인수인계하기 좋다. 4. 개발자 외에 관여자에게 설명하기 쉽다. 제가 권하고 싶은 log와 trace의 차이 및 활용법은 다음과 같습니다. log는 개발 과정에서 세밀한 것들을 확인할 때 활용될 수 있는 메시지이고, trace는 개발 외의 과정에서 프로그램의 동작을 확인할 때 활용될 수 있는 메시지 입니다. 다음 코드는 제가 작성한 코드 일부입니다. /** * Function : emulator * ----------------------- * Determine if current device is an emulator * * retur..

Facebook의 Redex 라는 프로젝트 코드를 참조하기 위해 보는 중 난해했던 코드를 만났습니다. void LocalDce::dce(IRCode* code, bool normalize_new_instances, DexType* declaring_type) { cfg::ScopedCFG cfg(code); dce(*cfg, normalize_new_instances, declaring_type); } DCE 옵티마이징 과정 중에 이런 코드가 있던거죠. bliveness |= liveness.at(s->target()->id()); 이게 무슨 코드인가? 했는데 dataflow analysis 에서 live analysis(?) 를 DCE에서 같이하는걸로 보이네요. 이에 대해선 차후 포스팅 할 기회가 있을..
최근에 면접을 보러 다니는데 제목과 같은 내용을 질문받아서 흥미롭다는 생각을 했습니다. 이 글은 해당 내용에 대해 다루고자 합니다. 1. LLVM libcxx 에 구현되어 있는 new _LIBCPP_WEAK void * operator new(std::size_t size) _THROW_BAD_ALLOC { if (size == 0) size = 1; void* p; while ((p = ::malloc(size)) == nullptr) { // If malloc fails and there is a new_handler, // call it to try free up memory. std::new_handler nh = std::get_new_handler(); if (nh) nh(); else #if..

소개글. Shuffle이란 단어는 카드 게임에서 카드를 섞을 때 사용되는 단어이다. shuffle을 ‘섞다’라고 한다면 Shuffler는 ‘섞는자’ 라고 하면 될까? Shuffler는 Control Flow Integrity와 동일한 Code-reuse attack = ‘실행 흐름의 변조/위조’ 를 방지하는 기술로 ROP, JOP와 같은 exploit 기법의 방어 기제에 대한 연구이다. Shuffler 요약. CFI기술은 compile 시 혹은 binary rewriting으로 실행 흐름에 무결성을 확보하기 위한 코드를 주입한다. 이를 통해 Control Flow의 변경 시(Call, Jmp 등) 목적지가 정당한 지를 검증하는 방식을 일반적으로 취하게 된다. 단점은, 그로 인해 CPU의 Branch Pr..

Control Flow Integrity for COTS Binaries august 2013 USENIX best paper awarded. (https://www.usenix.org/node/174767) “Security thesis review는 보안 관련된 논문의 개인 review로 다수의견과 일치되지 않을 수도 있습니다.” 소개글. Control Flow Integrity(이하 CFI)는 많이 연구되는 분야로 Return Oriented Program(ROP), Jump Oriented Program(JOP)와 같은 Code reuse 공격 기법에 대한 방어 기법이다. 2013년 발표된 이 논문에서는 CFI를 real-world에 적용하기 위한 방안에 대한 연구 내용을 다루고 있다. 배경. 기..
mangling 이 필요해진 이유 define internal i32 @"int ArithmeticOpInt.add_int(int, int)"(i32 %v1, i32 %v2) { bb: %0 = alloca i32, align 4 store i32 %v1, ptr %0, align 4 %1 = load i32, ptr %0, align 4 %2 = alloca i32, align 4 store i32 %v2, ptr %2, align 4 %3 = load i32, ptr %2, align 4 %4 = add i32 %1, %3 ret i32 %4 } 위처럼 테스트용 DEX에 산술연산 테스트용 메소드를 작성해 LLVM IR 로 변경했다. 컴파일은 문제 없이 진행된다. 컴파일 한 뒤 objdump 로 심볼을..
모종의 이유로 Linux에서 AOSP를 빌드한 후 DEX를 실행하고 싶다면 이 글이 도움이 될 겁니다. 먼저 Linux에서 AOSP를 빌드할 때 사용하시는 컴퓨터에 맞는 아키텍처로 빌드하세요. 아직까지 AOSP는 x86에서만 빌드할 수 있으므로 x86_64를 선택하시면 될겁니다. dalvikvm을 실행하기 위한 스크립트 : #!/bin/sh # base directory, at top of source tree; replace with absolute path base=`pwd` # configure root dir of interesting stuff root=$base/out/target/product/generic_x86_64/system export ANDROID_ROOT=$root # confi..