📔
Cyber Security Notes
  • Introduction
  • CVEs
    • CVE-2022-33106
  • Paper Reviews
    • Imperfect Forward Secrecy: How Diffie-Hellman Fails in Practice
  • Security Basics Notes
    • Identification, Authentication and Authorization
  • Enumeration and Initial Compromise
    • Methodology
    • Footprinting
    • Network Protocols
      • FTP
      • SMB
      • DNS
      • NFS
      • SMTP
      • IMAP/POP3
      • SNMP
      • MySQL
      • MSSQL
      • Oracle TNS
      • IPMI
    • Nifty One Liners
    • Brute-Force Web Pages
      • Hydra
    • Network Pentest
      • Quick SMB cheatsheet
      • SSH keypair basics
      • Compromise using SSH Key
      • Networking fundamentals Interview topics
      • nmap quick cheatsheet
      • Metasploit Quick Reference
    • Web Pentest
      • Web Pentest Interview top topics
      • Wordpress Exploitation
      • Joomla Exploitation
      • Login Bypass using Cookie Tampering/Poisoning
      • Subdomain Enumeration
      • CSRF mitigation
      • XSS mitigation
      • CSP bypass with JSONP
      • PHP Vulnerabilities
      • Python Serialization Vulnerabilities - Pickle
      • SQL Injections
        • SQLmap
      • SSTI
      • XSS
    • Buffer Overflow Prep
      • Understanding CPUs
      • Virtual Memory and Paging
      • Syscalls
      • Theorem Proving
      • Stripping readable function names
      • Insecure C functions
      • Stack Canaries
      • Linking - GOT,PLT
      • Return Oriented Programming
    • Active Directory - Basics
      • AD DS
      • Managing OUs
      • Group Policies
      • Authentications
      • Trees, Forests and Trusts
      • Kerberos
      • Attacking Kerberos
      • Priv Esc (Post Exploitation)
    • DNS/Domain Enum Masterguide
  • Post Exploitation
    • Shell Escape Techniques
    • Getting stable shell after compromise
    • Linux Privilege Escalation
      • Sudoers file
      • Sudoers entry - Yum
      • Wildcards - Basics
      • Wildcards - Chown
      • Wildcards - Tar
      • Linux Permissions & SUID/SGID/Sticky Bit
      • SUID - nmap
      • SUID - bash
      • SUID - man
      • NFS no_root_squash
      • SUID - pkexec
      • Bad permissions
    • Windows Privilege Escalation
      • SeImpersonatePrivilege Token Impersonation
      • Firefox Creds
      • Potatoes
      • Print Spooler Basics
      • Print Spooler CVE 2020-1030
      • SpoolFool
    • Data Exfiltration Post Exploitation
  • Port Forwarding Cheatsheet
  • Powershell Essentials
    • Powershell Basics
    • Powershell Enumeration
    • Powershell Port Scanner
    • Powershell One Liner Port Scanning
    • Powershell Port Scan in a given CIDR
  • Application Security
    • System Calls in Linux
    • Buffer Overflow Defenses
    • Format string vulnerabilities
    • Sample Github Actions
    • Basic Bugs in Demo Application
    • Using AFL++
  • Linux 64-bit Assembly
    • GDB Basics
      • My relevant GDB cheatsheet
      • Task 1 - Tamper strcmp logic
      • Breakpoints
      • Always starting with intel flavor
      • GDB TUI Mode
    • Basic Hello World Program
    • Registers in 64-bit
    • global directive
    • Reducing instructions and Removing NULL-> Optimizing memory in Assembly
    • Data Types
    • Endianness
    • Moving Data
    • push, pop, and the stack
    • Analysis - Writing data on memory location and referencing
    • Arithmetic Operations
    • Bitwise Logical Operations
    • Bit-Shifting Operations
    • Control Instructions
    • Loops
    • Procedures
    • Stack-Frames and Procedures
    • String Operations
    • Shellcoding basics
      • Introduction and Common Rules
      • Basic Shellcodes->Exit
      • Testing shellcode->Skeleton Code
      • Techniques-> JMP,CALL,POP
      • Techniques-> Stack
      • Techniques-> (64-bit only) RIP Relative Addressing
      • Shellcode 1 -> execve(/bin/sh) STACK PUSH
      • Shellcode 1 -> execve(/bin/sh) JMP CALL POP
      • Techniques-> XOR-Encoder
  • Cloud Security
    • Foundational Technology
    • Learning Through Project Omega
    • IAM Essentials
      • Deep dive into IAM - Part 1
    • Amazon S3
    • Risk Management & Data Controls
    • Enumeration
      • S3 - Enum Basics - PwnedLabs
      • S3 - Identify the AWS Account ID from a Public S3 Bucket
      • EBS - Loot Public EBS Volumes
      • S3- Exploit Weak Bucket Policies for Privileged Access
  • API Security
    • WSDL
  • Reverse Engineering
    • Some string Operations
    • Numbers and Inputs
    • Address inputs
    • Recursive Function
    • Crackme: level1
    • Crackme: level2
    • CTF: Memory Dereferencing
    • CTF: Monty Python
  • CTF Challenge Learnings
    • vsCTF 2024
      • Sanity Check
      • not-quite-caesar
      • Intro to reversing
    • NCL Individual 2024
      • Web Challenges
        • PiratePals
        • Pierre's Store
    • Pico CTF 2024
      • Web Exploitation
        • Bookmarklet
        • WebDecode
        • Unminify
        • Trickster
      • General Skills
        • Commitment Issues
        • Time Machine
        • Blame Game
        • Collaborative Development
        • Binary Search
        • Dont-you-love-banners
    • Sunshine CTF
      • Knowledge Repository
    • Amazon WiCys CTF
      • I am Lazy
      • Password Locker on the Web
      • Happy Birthday Card Generator
      • Bloggergate
      • simple offer
      • Bad Actor
      • Secret Server
      • Simple PCAP
      • Hidden Message
    • C code using getenv()
    • Command Injection with filter
    • Pwning
      • Shoddy_CMP
      • PLT_PlayIT
  • Applied Cryptography
    • Linear Congruential Generator
  • Tools for everything
Powered by GitBook
On this page

Was this helpful?

  1. Reverse Engineering

Numbers and Inputs

PreviousSome string OperationsNextAddress inputs

Last updated 1 year ago

Was this helpful?

Filename: numerix (elf64)

Decompilation gives us this:

Simplifying this in C, something like this comes up:

int main(EVP_PKEY_CTX *param_1)

{
  int a;
  uint b;
  long c;
  int d;
  
  init(param_1);
  puts("HEY!! I forgot my favorite numbers...");
  puts("Can you get them from my diary?");
  puts("What\'s my favoritest number?");
  c = get_number();
  if (c == 0xdeadbeef) {
    puts("What\'s my second most favorite number?");
    a = get_number();
    if (a == 0x539) {
      puts("Ok, you\'re pretty smart! What\'s the next one?");
      c = get_number();
      if (c == 0xc0def001337beef) {
        puts("YEAAAAAAAAAH you\'re doing GREAT! One more!");
        b = get_number();
        if ((b & 0xf0f0f0f0) == 0xd0d0f0c0) {
          puts("Awwwwww yeah! You did it!");
          print_flag();
          d = 0;
        }
        else {
          puts("Darn, so close too...");
          d = 1;
        }
      }
      else {
        puts("Ugh, ok, listen, you really need to hit the books...");
        d = 1;
      }
    }
    else {
      puts("What? NO! Try again!!");
      d = 1;
    }
  }
  else {
    puts("No! No! No! That\'s not right!");
    d = 1;
  }
  return d;
}

Things understood:

  1. Program prompts for 4 inputs through a function "get_number()"

  2. Guess all 4 correctly to reveal flag through print_flag()

  3. BUT WAIT. All the numbers are already on the screen in hex. Fishy.

  4. get_number()'s functionality is unknown

Let's inspect get_number()

So it is taking up a string of max 128 (hex 0x80) characters as input and then using strtol() to convert the input into something. Interesting.

strtol(input,(char **)0x0,10) -> return type long int.

This line means that whatever the input is in string, just extract the number part of it, send the string part to a null pointer (discard it)

For Example: see how strtol works on a string that has an integer and some characters.

So, cool, get_number would just help us input our numbers.

Line 15 compares the input with "0xdeadbeef". Using python to convert this in integer:

Lets try to input this in the program and confirm if we are on the right track or not

Yes! We are on the right track. Similarly converting next 2 inputs we find: 1337, 868613086753832687

Finally, whatever I input would be bitwise AND with 0xf0f0f0f0 and that should be equal to d0d0f0c0

So,

B AND f0f0f0f0 = d0d0f0c0

Mathematically,

B AND f0f0f0f0 AND f0f0f0f0 = d0d0f0c0 AND f0f0f0f0

Therefore,

B AND 1 = d0d0f0c0 AND f0f0f0f0

As per the truth table of AND, 1 AND 1 is 1 and rest all is 0

So, let's say B is 010101010101

B AND 1 = 010101010101 AND 1111111111111 still remains 01010101010101

Thus, B AND 1 is B

So, B is d0d0f0c0 AND f0f0f0f0 in decimal is 3503354048

Inputting these we GET!!!