😈
ReverseMe
  • Introduction
  • References
  • ReverseMe
    • Introduction
      • What is Reverse Engineering?
      • Legality of Reverse Engineering
      • Reverse Engineering Communities
  • Programming Language
    • C
      • Basic
        • Pointer
        • Casting
      • Reference
        • stdio.h
          • fclose()
          • fopen()
          • fseek()
          • ftell()
          • fgetc()
          • fgets()
          • fread()
          • fprintf()
          • fwrite()
          • printf()
          • putchar()
          • puts()
          • sprintf()
          • snprintf()
        • stdlib.h
          • malloc()
          • calloc()
          • realloc()
          • free()
          • rand()
          • srand()
        • string.h
          • strcat()
          • strncat()
          • strcmp()
          • strncmp()
          • strcpy()
          • strncpy()
        • time.h
          • time()
  • Reversing Fundamentals
    • Stripped and Unstripped
  • Tools
    • file
    • strings
    • ltrace
    • ghidra
  • CTF Writeups
    • HackTheBox Challenges
      • Baby RE
      • You Cant C Me
  • ABOUT ME
    • Mail
    • LinkedIn
    • GitHub
Powered by GitBook
On this page
  • Apa itu strings?
  • Contoh Pengunaan
  1. Tools

strings

PreviousfileNextltrace

Last updated 3 months ago

Apa itu strings?

adalah perintah yang digunakan untuk menampilkan urutan karakter (string) yang dapat dibaca dari sebuah file biner.

Perintah ini berguna untuk mencari teks-teks yang ada pada file executable atau file non-teks lainnya.

Contoh Pengunaan

Sebagai contoh, kita akan membuat program sederhana dalam bahasa C yang mengadung beberapa string:

main.c
#include <stdio.h>
#include <string.h>

int main() {
    char key[20];
    printf("Enter key: ");
    scanf("%19s", key);  // Membaca input maksimal 19 karakter
    if (strcmp(key, "secret") == 0) {
        printf("Access Granted\n");
    } else {
        printf("Access Denied\n");
    }
    return 0;
}

Kompilasi kode program tersebut, kemudian jalankan tools strings untuk melihat string yang ada di dalam file biner:

# -o test: menghasilkan executable dengan nama 'test'
➜ gcc -o test main.c

# Menampilkan string yang ditemukan dalam executable 'test'
➜ strings test
           
J/lib64/ld-linux-x86-64.so.2
puts    
__libc_start_main
__cxa_finalize    
printf      
__isoc99_scanf    
strcmp        
libc.so.6                                
GLIBC_2.7     
GLIBC_2.2.5
GLIBC_2.34
_ITM_deregisterTMCloneTable
__gmon_start__
_ITM_registerTMCloneTable
PTE1
u+UH
Enter key: 
%19s
secret
Access Granted
Access Denied
;*3$"
GCC: (Debian 14.2.0-16) 14.2.0
Scrt1.o
__abi_tag
crtstuff.c
deregister_tm_clones
__do_global_dtors_aux
completed.0
__do_global_dtors_aux_fini_array_entry
frame_dummy
__frame_dummy_init_array_entry
main.c

..<SNIPPED>..

Terlihat bahwa string yang ada di fungsi seperti printf, strcmp, dan scanf dalam file biner dapat ditemukan. Dalam kasus ini, string yang berkaitan dengan kunci validasi input ("secret") dapat diperoleh menggunakan perintah strings.

strings