블로그 이미지
Flying Mr.Cheon youGom

Recent Comment»

Recent Post»

Recent Trackback»

« 2024/5 »
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 31

 
 

reverse shell ssh

보안 | 2023. 5. 14. 21:20 | Posted by youGom

not netcat, it is ssh

install openssh server

$ sudo apt install openssh-server

check status ssh

$ sudo systemctl status ssh

if not work it ssh

$ sudo systemctl enable ssh
$ sudo systemctl start ssh

 

access the target server from client, if you had key-file, to include -i option.

$ ssh -R server_port:localhost:client_port user@server_ip
$ ssh -nNT -o TCPKeepAlive=yes -R server_port:127.0.0.1:client_port user@server_ip

'보안' 카테고리의 다른 글

[CURL] linux에서 활용하기  (0) 2014.11.28
[보안/교육] 아카데미 사이트  (0) 2013.07.18
BackTrack5 한글 패치하기  (0) 2013.03.27
:

'보안 > 기술 정보' 카테고리의 다른 글

die 2.0.5 detect it easy  (0) 2020.05.08
Monitoring BlockChain  (0) 2019.01.24
Excute BlockChain - Hello World  (0) 2019.01.24
[보안] SSH tunneling port forwarding (터널링)  (0) 2018.03.07
[Captcha] 캡챠 우회 하기  (0) 2017.08.03
:

die 2.0.5 detect it easy

보안/기술 정보 | 2020. 5. 8. 14:30 | Posted by youGom
:

.NET PublicKeyToken

보안/리버싱 | 2020. 4. 24. 20:35 | Posted by youGom

c# 실행파일 하나 디컴파일 하다, 잘 안되길래 살펴보다 보니 publickeytoken 이라는 걸 활용하는 것 같아서 살펴봄.

어떻게 만들어지는지 참조해놓고, 이 걸 이용해서 풀어야 하는건지 살펴볼 예정,

 

--------------------------------------------------------------------

 

echo 'csharp code, bla bla bla' > main.cs

 

sn -k first.key

sn -p first.key first_pub.key

 

sn -tp first_pub.key

>> public key token ......

 

csc /keyfile:first.key /out:temp.dll /t:library main.cs

>> make temp.dll

 

ildasm /out:info.txt temp.dll

>> view info.txt

 

csc /r:temp.dll main.cs

>> make main.exe

 

ildasm /out:final.txt main.exe

>> view final.txt

 

--------------------------------------------------------------------

 

아래 영상은 검색하다 찾은 영상,

 

 

 

 

:

AFL + Android / AOAP Porting and Fuzzing

보안/도구 | 2019. 6. 28. 12:25 | Posted by youGom

AOSP 를 다운로드 받고, 여기에 AFL 다운로드 받은 후 env 환경 설정 및 설치 진행

AOSP 다운받아보니 약 7.2기가정도 됨, 다운로드 실행시켜두고 다음날 확인했었음

git : https://github.com/ele7enxxh/android-afl

 

ele7enxxh/android-afl

Fuzzing Android program with american fuzzy lop (AFL) - ele7enxxh/android-afl

github.com

아래 접힌 내용은 위 git에서 설명 해주는 글 갈무리해둔 것임(영어임)

...더보기

android-afl

Fuzzing Android program with american fuzzy lop (AFL)

android-afl: Android-enabled version of AFL

android-afl is a modified version of AFL that supports fuzzing on Android, the SHM has been replaced with ASHMEM because of Android disable SHM in the kernel. Extra codes have been added in afl-gcc.c, afl-as.c and afl-as.h to support arm arch. Android.mk has been added to support Android build system and llvm_mode. Please refer to the android-afl.patch for more details.

Requirements

  • Android source code(e.g. 6.0.1) is needed.
  • llvm-5.0 and clang-5.0 are needed to provide support for llvm_mode on Android, you can install using apt-get install llvm clang on Ubuntu.

Build

first, download and build the Android open-source project (AOSP). then, download all the android-afl source code to AOSP folder:

cd AOSP

git clone https://github.com/ele7enxxh/android-afl

to build:

. build/envsetup.sh

cd android-afl mm

this will produce all afl binaries that you can use on host(e.g. Linux) or Android.

Usage

afl-gcc/afl-g++, afl-clang/afl-clang++ and afl-clang-fast/afl-clang-fast++ are all supported in android-afl. Please refer to android-afl-test for more details.

To fuzz

if you want fuzz on host, you should use the afl-fuzz in the $(HOST_OUT)/bin folder, otherwise you need to use the afl-fuzz in the $(target_OUT)/bin folder. To ingore bind_to_free_cpu, the AFL_NO_AFFINITY=1 should been set. Please refer to AFl README for more details.

Note

not all of the AFL tools have been tested on Android, but afl-fuzz has been working great on android-6.0.1 for me.

adb devices adb push ../out/target/product/generic/system/bin/ /data/local/tmp

 

한글로 간단히,

1) AOSP 다운받고 이 사이트에서 알려준데로 셋팅하고, Android open-source project (AOSP).

2) 'cd AOSP' 로 이동해서,

   AFL 받고,

   git clone https://github.com/ele7enxxh/android-afl

 

ele7enxxh/android-afl

Fuzzing Android program with american fuzzy lop (AFL) - ele7enxxh/android-afl

github.com

3) AOSP 폴더 위에서 환경셋 실행하고,

  . build/envsetup.sh

4) AFL을 빌드해준다

   cd android-afl

   mm

 

나는 빌드중에, O_CREAT 오류가 두군데 발생함, afl-fuzz.c, afl-showmap.c 여기서 발생했는데,

오류 내용이 open()함수 사용에서 O_CREAT 플래그 어쩌고 하길래, 그냥 그 플래그를 추가해주고 빌드시킴.

그랬더니, 약간의 수고 끝에 빌드 컴플릿 뜸. AFL 빌드시간 3분 54초 걸렸음.

 

Android 환경 셋 끝~

 

AOSP 다운로드 받고, 이 사이트에서 가이드 해주는게 더 빡센듯;; ㅋㅋ

'보안 > 도구' 카테고리의 다른 글

AFL fuzzer / fuzzing  (0) 2019.06.27
hollywood 스크립트 설치 (헐리우드)  (0) 2019.01.25
[도구] ADB 명령어 정리 내용 ( am/pm/capture/mongkey 등 )  (0) 2018.03.19
공유 게시판 이더패드  (0) 2015.03.30
[NMAP] MS-SQL pentest  (0) 2014.11.17
:

AFL fuzzer / fuzzing

보안/도구 | 2019. 6. 27. 17:42 | Posted by youGom

하기 사이트에 잘 정리 되어 있음

ref : https://www.lazenca.net/display/TEC/AFL+-+American+fuzzy+lop

 

AFL - American fuzzy lop - TechNote - Lazenca.0x0

Excuse the ads! We need some help to keep our site up. List Description AFL(American Fuzzy Lop)은 테스트 케이스의 코드 적용 범위(Code coverage)를 효율적으로 늘리기 위해 유전자 알고리즘(Genetic algorithm)을 사용하는 fuzzer입니다.지원 가능한 OS는 Linux, OpenBSD, FreeBSD, NetBSD의 32bit 및 64bit를 지원합니다.Mac

www.lazenca.net

...더보기
Description
  • AFL(American Fuzzy Lop)은 테스트 케이스의 코드 적용 범위(Code coverage)를 효율적으로 늘리기 위해 유전자 알고리즘(Genetic algorithm)을 사용하는 fuzzer입니다.
    • 지원 가능한 OS는 Linux, OpenBSD, FreeBSD, NetBSD의 32bit 및 64bit를 지원합니다.
      • MacOS X 및 Solaris에서도 작동하지만 일부 제약이 있습니다. 
    • 지원 가능한 프로그램 언어는 C, C++, Objective C를 지원합니다.
    • 지원 가능한 컴파일러는 gcc, g++, clang, clang++를 지원합니다.
    • 지원 가능한 테스트 방식은 White-box, Black-box를 지원합니다.
      • 리눅스에서는 QEMU 옵션을 사용해서 블랙 박스 바이너리를 퍼징 할 수 있습니다.

Site

Install

$ wget http://lcamtuf.coredump.cx/afl/releases/afl-latest.tgz $ tar -xvf afl-latest.tgz $ cd afl-2.49b/ $ make $ sudo make install

Commands

CommandDescriptionBasic methods of useafl-analyzeafl-clangafl-clang++afl-cminafl-fuzzafl-g++afl-gccafl-gotcpuafl-plotafl-tminafl-whatsup

파일 포맷 분석기

afl-analyze -i <test case file> target_app

clang wrapper

clang 명령어와 동일합니다.

clang++ wrapper

clang++ 명령어와 동일합니다.

중복되는 테스트 케이스 제거

afl-cmin -i <test case dir> -o <output dir> target_app

AFL의 코드 퍼지

afl-fuzz -i <test case dir> -o <output dir> target_app

g++ wrapper

g++명령어와 동일합니다.

gcc wrapper

gcc 명령어와 동일합니다.

CPU 선점 비율 출력

afl-gotcpu

진행률 출력- "gnuplot" 설치 필요

afl-plot <afl state dir> <graph output dir>

테스트 케이스 최소화

afl-tmin -i <test case file> -o <output file> target_app

상태 점검 도구

afl-whatsup <afl_sync_dir>

Description of commands

afl-fuzz

  • 해당 도구는 바이너리를 대상으로 다양한 퍼징을 시도합니다.

White-box, Black-box test

  • 해당 도구는 White-box, Black-box 테스트를 지원합니다.
    • White-box를 사용하기 위해서 afl에서 제공하는 컴파일러를 이용해 바이너리를 빌드해야 합니다.
    • Black-box를 사용하기 위해 afl에서는 QEMU를 사용하며, -Q 옵션을 이용해 사용할 수 있습니다.
  • 다음과 같이 White-box 테스트를 할 수 있습니다.

White-box

afl-fuzz -i <test case dir> -o <output dir> target_app

  • 다음과 같이 black-box 테스트를 할 수 있습니다.

Black-box

afl-fuzz -Q -i <test case dir> -o <output dir> target_app

데이터 입력 옵션

Standard input

afl-fuzz -i <test case dir> -o <output dir> target_app [params...]

File input

afl-fuzz -i <test case dir> -o <output dir> target_app @@

Parallel fuzzing

  • 해당 도구는 병렬 퍼징을 지원합니다.

    • afl-fuzz의 모든 복사본은 하나의 CPU 코어를 차지합니다. 

    • 즉,n 코어 시스템에서는 거의 항상 성능 저하없이 거의 동시 n 개의 동시 퍼징 작업을 실행할 수 있습니다 

      • afl-gotcpu 도구를 사용하여 확인할 수 있음

    • 사실 멀티 코어 시스템에서 단 하나의 작업에만 의존한다면 하드웨어를 충분히 활용 하지 못할 것 입니다.

    • 병렬 처리가 일반적으로 올바른방법입니다.

Single-system parallelization

  • 단일 시스템 병렬화를 이용하기 위해 로컬 시스템의 여러 코어에 단일 작업을 병렬로 연결하기위한 빈 디렉토리("sync dir")를 생성합니다.

    • 해당 디렉토리에 모든 인스턴스가 공유됩니다.

  • 다음과 같이 마스터 인스턴스(-M)를 실행합니다.

마스터 인스턴스

./afl-fuzz -i testcase_dir -o sync_dir -M fuzzer01 [...other stuff...]

    • 다음과 같이 보조 인스턴스(-S)를 실행합니다.

보조 인스턴스

$ ./afl-fuzz -i testcase_dir -o sync_dir -S fuzzer02 [...other stuff...] $ ./afl-fuzz -i testcase_dir -o sync_dir -S fuzzer03 [...other stuff...]

Multi-system parallelization

  • 다중 시스템 병렬화 처리의 기본 작동 원리는 단일 시스템 병렬화에서 설명한 메커니즘과 비슷합니다. 
  • 두 가지 작업을 수행하는 간단한 스크립트가 필요합니다.
  • 로컬 시스템에서 모든 <fuzzer_id> 디렉토리의 "/queue/" 경로 아래에 있는 파일들을 압축합니다.

for s in {1..10}; do ssh user@host${s} "tar -czf - sync/host${s}_fuzzid*/[qf]*" >host${s}.tgz done

  • 압축된 파일을 모든 컴퓨터에 파일을 배포하고 압축을 해제합니다

for s in {1..10}; do for d in {1..10}; do test "$s" = "$d" && continue ssh user@host${d} 'tar -kxzf -' <host${s}.tgz done done

Parallel fuzzing using AFL

afl-analyze

  • 해당 도구는 Test case의 파일 포맷을 분석합니다.

    • 데이터 스트림으로 부터 순차적으로 전달되는 데이터들을 가져오며, 매 입력마다 바이너리의 동작을 관찰합니다.

  • 다음과 같은 정보를 유추 할 수 있습니다.

    • no-op block

    • Critical stream

    • "magic value" 섹션

    • 내용으로 의심되는 영역

    • 길이 필드로 의심되는 영역

    • 체크섬 블럭으로 의심되는 영역

    • 체크썸 또는 Magic 값으로 의심되는 영역

  • 다음과 같이 사용할 수 있습니다.

afl-analyze -i testcase/test1.txt ./test

lazenca0x0@ubuntu:~/Documents/AFL/test$ afl-analyze -i testcase/test1.txt ./test afl-analyze 2.49b by <lcamtuf@google.com> [+] Read 4 bytes from 'testcase/test1.txt'. [*] Performing dry run (mem limit = 50 MB, timeout = 1000 ms)... [*] Analyzing input file (this may take a while)... 01 - no-op block 01 - suspected length field 01 - superficial content 01 - suspected cksum or magic int 01 - critical stream 01 - suspected checksummed block 01 - "magic value" section [000000] a #0a a #0a [+] Analysis complete. Interesting bits: 0.00% of the input file. [+] We're done here. Have a nice day! lazenca0x0@ubuntu:~/Documents/AFL/test$

afl-cmin

  • 해당 도구는 Test case의 중복을 최소화 합니다.
  • 다음과 같이 가장 적합한 test case만을 분리 합니다.
    • 4개의 test case에서 7개의 tuple을 발견했으며, 2개의 파일로 축소했습니다.
    • 여기서 사용된 test case는 아래 "Create to Test cases."에서 생성한 파일을 사용했습니다.

afl-cmin -i testcase/ -o newTestCase/ ./test

lazenca0x0@ubuntu:~/Documents/AFL/test$ afl-cmin -i testcase/ -o newTestCase/ ./test corpus minimization tool for afl-fuzz by <lcamtuf@google.com> [*] Testing the target binary... [+] OK, 4 tuples recorded. [*] Obtaining traces for input files in 'testcase/'... Processing file 4/4... [*] Sorting trace sets (this may take a while)... [+] Found 7 unique tuples across 4 files. [*] Finding best candidates for each tuple... Processing file 4/4... [*] Sorting candidate list (be patient)... [*] Processing candidates and writing output files... Processing tuple 7/7... [+] Narrowed down to 2 files, saved in 'newTestCase/'. lazenca0x0@ubuntu:~/Documents/AFL/test$ cd newTestCase/ lazenca0x0@ubuntu:~/Documents/AFL/test/newTestCase$ ls -al total 16 drwxrwxr-x 2 lazenca0x0 lazenca0x0 4096 Aug 15 20:08 . drwxrwxr-x 5 lazenca0x0 lazenca0x0 4096 Aug 15 20:08 .. -rw-rw-r-- 2 lazenca0x0 lazenca0x0 4 Aug 9 00:18 test1.txt -rw-rw-r-- 2 lazenca0x0 lazenca0x0 9 Aug 9 00:19 test3.txt lazenca0x0@ubuntu:~/Documents/AFL/test/newTestCase$

afl-tmin

  • 해당 도구는 Test case의 최적화를 진행합니다.
  • 최적화되는 내용은 다음과 같습니다.
    • 데이터 블럭의 최소화
    • 기호의 최소화
    • 문자의 최소화
  • 다음과 같이 Test case를 최소화 할 수 있습니다.
    • 68개의 문자가 56개로 변경되었습니다.
    • 임의 문자들이 숫자 0(0x30)으로 변경되었습니다.
    • Test case에 기호가 없었기 때문에 기호의 최소화는 진행되지 않았습니다.

afl-tmin -i result/crashes/id\:000000\,sig\:11\,src\:000000\,op\:havoc\,rep\:128 -o testcaseMin ./test

lazenca0x0@ubuntu:~/Documents/AFL/test$ afl-tmin -i result/crashes/id\:000000\,sig\:11\,src\:000000\,op\:havoc\,rep\:128 -o testcaseMin ./test afl-tmin 2.49b by <lcamtuf@google.com> [+] Read 68 bytes from 'result/crashes/id:000000,sig:11,src:000000,op:havoc,rep:128'. [*] Performing dry run (mem limit = 50 MB, timeout = 1000 ms)... [+] Program exits with a signal, minimizing in crash mode. [*] Stage #0: One-time block normalization... [+] Block normalization complete, 68 bytes replaced. [*] --- Pass #1 --- [*] Stage #1: Removing blocks of data... Block length = 4, remaining size = 68 Block length = 2, remaining size = 56 Block length = 1, remaining size = 56 [+] Block removal complete, 12 bytes deleted. [*] Stage #2: Minimizing symbols (1 code point)... [+] Symbol minimization finished, 0 symbols (0 bytes) replaced. [*] Stage #3: Character minimization... [+] Character minimization done, 0 bytes replaced. [*] --- Pass #2 --- [*] Stage #1: Removing blocks of data... Block length = 4, remaining size = 56 Block length = 2, remaining size = 56 Block length = 1, remaining size = 56 [+] Block removal complete, 0 bytes deleted. File size reduced by : 17.65% (to 56 bytes) Characters simplified : 121.43% Number of execs done : 33 Fruitless execs : path=12 crash=0 hang=0 [*] Writing output to 'testcaseMin'... [+] We're done here. Have a nice day! lazenca0x0@ubuntu:~/Documents/AFL/test$ hexdump result/crashes/id\:000000\,sig\:11\,src\:000000\,op\:havoc\,rep\:128 0000000 81b9 ad13 0000 76e1 04ff 007f eee7 ffff 0000010 64ff 0000 798a 9379 7980 7979 7966 e100 0000020 ff76 7fc0 e700 ffee ffff ffff 7f04 e700 0000030 ffee ffff 0064 6900 7979 7993 7979 0079 0000040 0100 ff00 0000044 lazenca0x0@ubuntu:~/Documents/AFL/test$ hexdump testcaseMin 0000000 3030 3030 3030 3030 3030 3030 3030 3030 * 0000038 lazenca0x0@ubuntu:~/Documents/AFL/test$ cat testcaseMin 00000000000000000000000000000000000000000000000000000000

afl-gotcpu

  • 해당 도구는 afl-fuzz에서 사용중인 cpu 선점 비율을 출력합니다.

afl-gotcpu

lazenca0x0@ubuntu:~$ afl-gotcpu afl-gotcpu 2.49b by <lcamtuf@google.com> [*] Measuring per-core preemption rate (this will take 1.00 sec)... Core #0: CAUTION (231%) >>> CAUTION: You may still have 1 core available. <<< lazenca0x0@ubuntu:~$

afl-plot

  • 해당 도구는 fuzz의 진행 상황을 그래프로 출력합니다.
  • 다음과 같이 해당 프로그램을 실행하면, index.html 파일이 생성됩니다.

afl-plot result/ graph/

lazenca0x0@ubuntu:~/Documents/AFL/test$ afl-plot result/ graph/ progress plotting utility for afl-fuzz by <lcamtuf@google.com> [*] Generating plots... [*] Generating index.html... [+] All done - enjoy your charts! lazenca0x0@ubuntu:~/Documents/AFL/test$

index.html

 

alf-whatsup

  • 해당 도구는 병렬 퍼징을 진행했을 때 개별 fuzzer의 상태를 확인할 수 있습니다.

afl-whatsup result/

lazenca0x0@ubuntu:~/Documents/AFL/test$ afl-whatsup result/ status check tool for afl-fuzz by <lcamtuf@google.com> Individual fuzzers ================== >>> fuzzer1 (0 days, 0 hrs) <<< cycle 1, lifetime speed 1 execs/sec, path 0/2 (0%) pending 2/2, coverage 0.01%, no crashes yet >>> fuzzer2 (0 days, 0 hrs) <<< cycle 1, lifetime speed 1 execs/sec, path 0/2 (0%) pending 2/2, coverage 0.01%, no crashes yet Summary stats ============= Fuzzers alive : 2 Total run time : 0 days, 0 hours Total execs : 0 million Cumulative speed : 2 execs/sec Pending paths : 4 faves, 4 total Pending per fuzzer : 2 faves, 2 total (on average) Crashes found : 0 locally unique lazenca0x0@ubuntu:~/Documents/AFL/test$

Example

Example code

  • 아래 코드는 다음과 같은 동작을 합니다.
    • 사용자로 부터 ID, Password를 입력받습니다.
    • 입력받은 값이 프로그램이 요구하는 값과 일치하면 "Success"를 출력합니다.
    • 그렇지 않을 경우 "Fail"을 출력합니다.
  • 여기서 중요한 부분은 사용자로부터 입력 받는 값에 대한 길이 제한이 없다는 것입니다.
    • 이로 인해 Stack Buffer Overflow가 발생합니다.

test.c

#include <stdio.h> #include <string.h> int main(void){ char login[16]; char password[16]; printf("Login : "); scanf("%s",login); printf("Password : "); scanf("%s",password); if(strcmp(login,"root") == 0){ if(strcmp(password,"toor") == 0){ printf("Success.\n"); return 0; } } printf("Fail.\n"); return 1; }

Create to Test cases.

  • 다음과 같이 Test case를 생성합니다.
    • ID가 틀린 경우
    • Password가 틀린 경우
    • ID, Password 모두 틀린 경우
    • ID, Password 정확한 경우

Create to test cases.

lazenca0x0@ubuntu:~/Documents/AFL/test$ mkdir testcase lazenca0x0@ubuntu:~/Documents/AFL/test$ cd testcase lazenca0x0@ubuntu:~/Documents/AFL/test$ echo -e "a\toor" > test1.txt lazenca0x0@ubuntu:~/Documents/AFL/test$ echo -e "root\na" > test2.txt lazenca0x0@ubuntu:~/Documents/AFL/test$ echo -e "a\na" > test3.txt lazenca0x0@ubuntu:~/Documents/AFL/test$ echo -e "root\toor" > test4.txt lazenca0x0@ubuntu:~/Documents/AFL/test$

White-box testing

Build using afl-gcc.

  • 다음과 같이 AFL에서 제공하는 컴파일러를 이용해 빌드합니다.
    • 빌드된 파일이 정상적으로 동작하는 것을 확인 할 수 있습니다.
    • 테스트를 위해 Canary를 제거 합니다. (-fno-stack-protector)

afl-gcc -o test test.c

lazenca0x0@ubuntu:~/Documents/AFL/test$ afl-gcc -fno-stack-protector -o test test.c afl-cc 2.49b by <lcamtuf@google.com> test.c: In function 'main': test.c:9:2: warning: ignoring return value of 'scanf', declared with attribute warn_unused_result [-Wunused-result] scanf("%s",login); ^ test.c:11:2: warning: ignoring return value of 'scanf', declared with attribute warn_unused_result [-Wunused-result] scanf("%s",password); ^ afl-as 2.49b by <lcamtuf@google.com> [+] Instrumented 8 locations (64-bit, non-hardened mode, ratio 100%). lazenca0x0@ubuntu:~/Documents/AFL/test$ ./test Login : root Password : toor Success. lazenca0x0@ubuntu:~/Documents/AFL/test$ ./test Login : a Password : a Fail. lazenca0x0@ubuntu:~/Documents/AFL/test$

Run afl-fuzz

  • 다음과 같이 AFL을 실행하면 "uniq crashes"를 발견할 수 있습니다.
    • 테스트 프로그램에서 2개의 Uniq crashes를 발견하였습니다.
  • 옵션은 다음과 같습니다.
    • -i : Test case가 저장된 디렉토리 경로
    • -o : 탐지된 결과를 저장할 디렉토리 경로

Run AFL-fuzz

lazenca0x0@ubuntu:~/Documents/AFL/test$ echo core > /proc/sys/kernel/core_pattern lazenca0x0@ubuntu:~/Documents/AFL/test$ mkdir result lazenca0x0@ubuntu:~/Documents/AFL/test$ afl-fuzz -i testcase/ -o result/ ./test afl-fuzz 2.49b by <lcamtuf@google.com> [+] You have 1 CPU core and 2 runnable tasks (utilization: 200%). [*] Checking core_pattern... [*] Setting up output directories... [+] Output directory exists but deemed OK to reuse. [*] Deleting old session data... [+] Output dir cleanup successful. [*] Scanning 'testcase/'... [+] No auto-generated dictionary tokens to reuse. [*] Creating hard links for all input files... [*] Validating target binary... [*] Attempting dry run with 'id:000000,orig:test1.txt'... [*] Spinning up the fork server... [+] All right - fork server is up. len = 4, map size = 34, exec speed = 1428 us [*] Attempting dry run with 'id:000001,orig:test2.txt'... len = 7, map size = 37, exec speed = 596 us [*] Attempting dry run with 'id:000002,orig:test3.txt'... len = 14, map size = 38, exec speed = 740 us [+] All test cases processed. [+] Here are some useful stats: Test case count : 3 favored, 0 variable, 3 total Bitmap range : 34 to 38 bits (average: 36.33 bits) Exec timing : 596 to 1428 us (average: 921 us) [*] No -t option specified, so I'll use exec timeout of 20 ms. [+] All set and ready to roll! american fuzzy lop 2.49b (test) ┌─ process timing ─────────────────────────────────────┬─ overall results ─────┐ │ run time : 0 days, 0 hrs, 0 min, 17 sec │ cycles done : 16 │ │ last new path : none yet (odd, check syntax!) │ total paths : 3 │ │ last uniq crash : 0 days, 0 hrs, 0 min, 11 sec │ uniq crashes : 2 │ │ last uniq hang : none seen yet │ uniq hangs : 0 │ ├─ cycle progress ────────────────────┬─ map coverage ─┴───────────────────────┤ │ now processing : 1 (33.33%) │ map density : 0.06% / 0.07% │ │ paths timed out : 0 (0.00%) │ count coverage : 1.00 bits/tuple │ ├─ stage progress ────────────────────┼─ findings in depth ────────────────────┤ │ now trying : havoc │ favored paths : 3 (100.00%) │ │ stage execs : 136/256 (53.12%) │ new edges on : 3 (100.00%) │ │ total execs : 29.8k │ total crashes : 242 (2 unique) │ │ exec speed : 1729/sec │ total tmouts : 0 (0 unique) │ ├─ fuzzing strategy yields ───────────┴───────────────┬─ path geometry ────────┤ │ bit flips : 0/176, 0/173, 0/167 │ levels : 1 │ │ byte flips : 0/22, 0/19, 0/13 │ pending : 0 │ │ arithmetics : 0/1228, 0/148, 0/0 │ pend fav : 0 │ │ known ints : 0/118, 0/532, 0/572 │ own finds : 0 │ │ dictionary : 0/0, 0/0, 0/24 │ imported : n/a │ │ havoc : 2/13.6k, 0/12.9k │ stability : 100.00% │ │ trim : 14.29%/4, 0.00% ├────────────────────────┘ ^C────────────────────────────────────────────────────┘ [cpu:313%] +++ Testing aborted by user +++ [+] We're done here. Have a nice day! lazenca0x0@ubuntu:~/Documents/AFL/test$

Black-box testing

Install library files

  • Black box 테스트를 진행하기 위해 다음과 같은 설정이 필요합니다.
    • 설치 라이브러리 : libini-config-dev, libtool-bin, automake, bison, libglib2.0-dev, qemu

Install library files

lazenca0x0@ubuntu:~/Documents/AFL/afl-2.49b$ apt-get install libini-config-dev libtool-bin automake bison libglib2.0-dev qemu -y lazenca0x0@ubuntu:~/Documents/AFL/afl-2.49b$ cd qemu_mode/ lazenca0x0@ubuntu:~/Documents/AFL/afl-2.49b/qemu_mode/$ ./build_qemu_support.sh lazenca0x0@ubuntu:~/Documents/AFL/afl-2.49b/qemu_mode/$ cd .. lazenca0x0@ubuntu:~/Documents/AFL/afl-2.49b$ sudo make install

Build using gcc

  • 다음과 같이 gcc를 이용해 빌드합니다.

Build using gcc

lazenca0x0@ubuntu:~/Documents/AFL/test$ gcc -fno-stack-protector -o test test.c

Run afl-fuzz

  • 다음과 같이 Black box test를 진행할 수 있습니다.
    • Black box test를 진행하기 위해 -Q 옵션만 추가하면 됩니다.
    • White box test와 같이 2개의 uniq crashes를 발견하였습니다.

Run AFL-fuzz

lazenca0x0@ubuntu:~/Documents/AFL/test$ afl-fuzz -Q -i testcase/ -o result/ ./test afl-fuzz 2.49b by <lcamtuf@google.com> [+] You have 1 CPU core and 3 runnable tasks (utilization: 300%). [*] Checking core_pattern... [*] Setting up output directories... [+] Output directory exists but deemed OK to reuse. [*] Deleting old session data... [+] Output dir cleanup successful. [*] Scanning 'testcase/'... [+] No auto-generated dictionary tokens to reuse. [*] Creating hard links for all input files... [*] Validating target binary... [*] Attempting dry run with 'id:000000,orig:test1.txt'... [*] Spinning up the fork server... [+] All right - fork server is up. len = 4, map size = 33, exec speed = 1898 us [*] Attempting dry run with 'id:000001,orig:test2.txt'... len = 6, map size = 33, exec speed = 1048 us [!] WARNING: No new instrumentation output, test case may be useless. [*] Attempting dry run with 'id:000002,orig:test3.txt'... len = 9, map size = 36, exec speed = 790 us [*] Attempting dry run with 'id:000003,orig:test4.txt'... len = 6, map size = 33, exec speed = 806 us [!] WARNING: No new instrumentation output, test case may be useless. [+] All test cases processed. [!] WARNING: Some test cases look useless. Consider using a smaller set. [+] Here are some useful stats: Test case count : 2 favored, 0 variable, 4 total Bitmap range : 33 to 36 bits (average: 33.75 bits) Exec timing : 790 to 1898 us (average: 1135 us) [*] No -t option specified, so I'll use exec timeout of 20 ms. [+] All set and ready to roll! american fuzzy lop 2.49b (test) ┌─ process timing ─────────────────────────────────────┬─ overall results ─────┐ │ run time : 0 days, 0 hrs, 0 min, 10 sec │ cycles done : 5 │ │ last new path : none yet (odd, check syntax!) │ total paths : 4 │ │ last uniq crash : 0 days, 0 hrs, 0 min, 2 sec │ uniq crashes : 2 │ │ last uniq hang : none seen yet │ uniq hangs : 0 │ ├─ cycle progress ────────────────────┬─ map coverage ─┴───────────────────────┤ │ now processing : 1* (25.00%) │ map density : 0.05% / 0.06% │ │ paths timed out : 0 (0.00%) │ count coverage : 1.00 bits/tuple │ ├─ stage progress ────────────────────┼─ findings in depth ────────────────────┤ │ now trying : splice 7 │ favored paths : 2 (50.00%) │ │ stage execs : 30/32 (93.75%) │ new edges on : 2 (50.00%) │ │ total execs : 16.2k │ total crashes : 1204 (2 unique) │ │ exec speed : 1533/sec │ total tmouts : 0 (0 unique) │ ├─ fuzzing strategy yields ───────────┴───────────────┬─ path geometry ────────┤ │ bit flips : 0/128, 0/124, 0/116 │ levels : 1 │ │ byte flips : 0/16, 0/12, 0/4 │ pending : 0 │ │ arithmetics : 0/890, 0/176, 0/0 │ pend fav : 0 │ │ known ints : 0/80, 0/336, 0/176 │ own finds : 0 │ │ dictionary : 0/0, 0/0, 0/2 │ imported : n/a │ │ havoc : 1/7936, 1/6184 │ stability : 100.00% │ │ trim : 42.86%/4, 0.00% ├────────────────────────┘ ────────────────────────────────────────────────────┘ [cpu:303%] +++ Testing aborted by user +++ [+] We're done here. Have a nice day! lazenca0x0@ubuntu:~/Documents/AFL/test$

Check for the crash.

  • 다음과 같이 발견된 uniq crashes는 result 폴더에 저장되어 있습니다.
    • 해당 파일을 이용해 crash를 재현 할 수 있습니다.

Check for the crash.

lazenca0x0@ubuntu:~/Documents/AFL/test$ ls -al result/crashes/ total 20 drwx------ 2 lazenca0x0 lazenca0x0 4096 Aug 9 01:26 . drwxrwxr-x 5 lazenca0x0 lazenca0x0 4096 Aug 9 01:26 .. -rw------- 1 lazenca0x0 lazenca0x0 68 Aug 9 01:26 id:000000,sig:11,src:000000,op:havoc,rep:128 -rw------- 1 lazenca0x0 lazenca0x0 86 Aug 9 01:26 id:000001,sig:11,src:000002+000003,op:splice,rep:128 -rw------- 1 lazenca0x0 lazenca0x0 604 Aug 9 01:26 README.txt lazenca0x0@ubuntu:~/Documents/AFL/test$ ./test < result/crashes/id\:000000\,sig\:11\,src\:000000\,op\:havoc\,rep\:128 Login : Password : Fail. Segmentation fault lazenca0x0@ubuntu:~/Documents/AFL/test$ ./test < result/crashes/id\:000001\,sig\:11\,src\:000002+000003\,op\:splice\,rep\:128 Login : Password : Fail. Segmentation fault lazenca0x0@ubuntu:~/Documents/AFL/test$

  • 다음은 생성 crash 파일의 내용입니다.
    • 저장된 내용은 특별한 의미를 가지지 않습니다.

Crash file

lazenca0x0@ubuntu:~/Documents/AFL/test$ hexdump result/crashes/id\:000000\,sig\:11\,src\:000000\,op\:havoc\,rep\:128 0000000 81b9 ad13 0000 76e1 04ff 007f eee7 ffff 0000010 64ff 0000 798a 9379 7980 7979 7966 e100 0000020 ff76 7fc0 e700 ffee ffff ffff 7f04 e700 0000030 ffee ffff 0064 6900 7979 7993 7979 0079 0000040 0100 ff00 0000044 lazenca0x0@ubuntu:~/Documents/AFL/test$ hexdump result/crashes/id\:000001\,sig\:11\,src\:000002+000003\,op\:splice\,rep\:128 0000000 6f72 746f 0000 0004 5774 aaaa aaaa aaaa 0000010 aa97 aaaa 0000 8000 5774 aaaa 97a4 aaaa 0000020 00aa 0000 7480 aa57 9faa 72aa 6f6f aa74 0000030 aaaa 97a4 aaaa 16aa aaaa 619c aa57 aaaa 0000040 aaaa 97aa aaaa 00aa 0000 aa80 6f6f aaaa 0000050 72aa 6f6f 6f74 0000056

Related information

 

기본설치와 실행은 잘되지만, qemu_mode 설치 및 실행은 원활히 되지 않고, 오류가 발생함

오류 내용은 memfd.c 에서 발생하고, 이에 대해 해결한 코드는 아래 git에 있음

ref : https://github.com/abiondo/afl

 

abiondo/afl

My fork of American Fuzzy Lop. Contribute to abiondo/afl development by creating an account on GitHub.

github.com

qemu build 스크립트와 paches 내용이 적용되어 qemu_mode도 정상 작동함

현재 2019.6.27 일자로 qemu_mode 2.10.0을 다운로드 받아서 설치함.

 

아래 내용은 위 내용을 간략히 정리.

위 AFL 버젼은 2.49이지만, 테스트한 버젼은 2.52b 버젼임

 

기본 설치 내용

$ wget http://lcamtuf.coredump.cx/afl/releases/afl-latest.tgz

$ tar -xvf afl-latest.tgz

$ cd afl-2.49b/

$ make $ sudo make install

 

기본 테스트

$ afl-gcc -fno-stack-protector -o test test.c

# test.c 내용은 위에 상세히 적어둠

 

qemu_mode 설치 내용

$ apt-get install libini-config-dev libtool-bin automake bison libglib2.0-dev qemu -y

$ cd qemu_mode/

$ ./build_qemu_support.sh

$ cd ..

$ sudo make install

# afl_qemu_strace를 생성을 위해서 make install을 다시한번 더 함

 

최종 테스트

$ gcc -fno-stack-protector -o test test.c

# 기존 test파일은 afl-gcc로 만들어 진 것임

$ afl-fuzz -Q -i testcase/ -o result/ ./test @@

:

보호되어 있는 글입니다.
내용을 보시려면 비밀번호를 입력하세요.

hollywood 스크립트 설치 (헐리우드)

보안/도구 | 2019. 1. 25. 14:57 | Posted by youGom


sudo apt install hollywood
sudo apt-add-repository ppa:hollywood/ppa
sudo apt-get update
sudo apt-get install byobu hollywood



Hollywood on GitHub





Hollywood hacking terminal in Linux

 








아래와 같은 에러 발생 시 : byobu 관련 오류

  error can't open /usr/share/applications/byobu.desktop no such file directory


원본 : https://www.hiroom2.com/2017/09/21/parrotsec-3-8-byobu-en/

1 Error with installing byobu

The following error will be occured when installing byobu.

$ sudo apt install -y byobu
<snip>
update-parrot-menu: error: can't open
/usr/share/applications/byobu.desktop: No such file or directory
E: Problem executing scripts DPkg::Post-Invoke '[ ! -x
/usr/share/parrot-menu/update-parrot-menu ] ||
/usr/share/parrot-menu/update-parrot-menu wait_dpkg'
E: Sub-process returned an error code

2 Install byobu

Create lacked file after installing byobu and reinstall byobu.

$ sudo apt install -y byobu || true
$ cat <<EOF | sudo tee /usr/share/applications/byobu.desktop
[Desktop Entry]
Name=Byobu Terminal
Comment=Advanced Command Line and Text Window Manager
Icon=byobu
Exec=gnome-terminal --app-id us.kirkland.terminals.byobu -e byobu
Type=Application
Categories=GNOME;GTK;Utility;
X-GNOME-Gettext-Domain=byobu
EOF
$ sudo apt install --reinstall -y byobu


'보안 > 도구' 카테고리의 다른 글

AFL + Android / AOAP Porting and Fuzzing  (0) 2019.06.28
AFL fuzzer / fuzzing  (0) 2019.06.27
[도구] ADB 명령어 정리 내용 ( am/pm/capture/mongkey 등 )  (0) 2018.03.19
공유 게시판 이더패드  (0) 2015.03.30
[NMAP] MS-SQL pentest  (0) 2014.11.17
:

Monitoring BlockChain

보안/기술 정보 | 2019. 1. 24. 17:03 | Posted by youGom
geth \
    --rpc \
    --rpcport 8545 \
    --rpcaddr 127.0.0.1 \
    --rpccorsdomain 127.0.0.1 \
    --rpcapi "eth,web3,miner,net,admin,personal,debug" \
    --metrics \
    --bootnodes <your-bootnodes>
geth monitor --attach=http://127.0.0.1:8545 txpool
geth attach http://127.0.0.1:8545 --exec "debug.metrics(false).txpool"
geth attach http://127.0.0.1:8545 --exec "debug.metrics(false)"


:

Excute BlockChain - Hello World

보안/기술 정보 | 2019. 1. 24. 16:54 | Posted by youGom

[ Step 0 : Install : MAC ] - 리눅스일경우 다른 방법으로 설치하거나 빌드하면됨

$ brew tap ethereum/ethereum

$ brew install ethereum


[ Step 1 : Create Genesis Block ]

$ mkdir -p ethereum-tutorial && cd ethereum-tutorial

$ mkdir -p private && cd private

$ puppeth

 > anyname

 > 2. Configure new genesis

 > 1. Create new genesis from scratch

 > 1. Ethash - proof of work

 > 0x100000000000

 > (blank:Default pre-funded with 1wei )

 > 12345 ( networkID)

      << loop answer >>

 > 2. Manage existing genesis

 > 2. Export genesis configuration

 > ( Ctrl + C : breake process )

there are 4 files; 

anyname.json, 

anyname-parity.json 

anyname-harmony.json 

anyname-aleth.json


[Step 2 : Initialize the genesis block]

$ geth --data ~/.ethereum-tutorial/private init anyname.json


[Step 3: Creating accounts]

$ geth --datadir . account new

$ geth --datadir . account list


[Step 4: Write a Shell Script to Start Blockchain]

$ vi startnode.sh

geth --networkid 4224 --mine --minerthreads 1 --datadir "~/Desktop/Playground/ethereum-tutorial/private" --nodiscover --rpc --rpcport "8545" --port "30303" --rpccorsdomain "*" --nat "any" --rpcapi eth,web3,personal,net --unlock 0 --password ~/ethereum-tutorial/private/password.sec --ipcpath "~/Library/Ethereum/geth.ipc"

  << Create another file named password.sec in private folder. >>

$ chmod +x startnode.sh

$ ./startnode.sh


[Step 5: Connect to running geth]

$ geth attach --datadir ~/ethereum-tutorial


[Step 6: Query the blockchain]

> eth.accounts

> eth.getBalance(eth.accounts[0])

> web3.fromWei(eth.getBalance(eth.accounts[0]), "ether")


$ miner.stop()

$ miner.start()


[Step 7: Make transactions]

> eth.sendTransaction({from: eth.coinbase, to: eth.accounts[1], value: web3.toWei(10, "ether")})

> web3.fromWei(eth.getBalance(eth.accounts[1]), "ether")



: