Friday, October 16, 2020

Malware Dev 101:Reverse Engineering

 Hello reader,today we learn about malware!!yEY s00n we will be on APT(advenced persistance thread)level.Not yet....

Malware

How does one define malware? 

Wikipedia defines it as :"Malware (a portmanteau for malicious software) is any software intentionally designed to cause damage to a computer, server, client, or computer network[1][2] (by contrast, software that causes unintentional harm due to some deficiency is typically described as a software bug).[3] A wide variety of malware types exist, including computer viruses, worms, Trojan horses, ransomware, spyware, adware, rogue software, and scareware." Now generally malware is developed by Red Teams in a pentest engagement or by some other hacker with bad intent.

Reverse Engineering

Now we as defenders or Blue Teamers are supossed to be able to unpack,decrypt and analyse the code of malware for incident response.But what is even reverse engineering?Again wikipedia helps us:"Reverse engineering, also called backwards engineering or back engineering, is the process by which an artificial object is deconstructed to reveal its designs, architecture, code or to extract knowledge from the object."

So,baisically reverse engineering is the analysis process in order for us to develop signatures for out IDS/IPS or Firewall.

Now for a malware analyst to do reverse engineering he must know how to do programming or computer science.

Reverse Engineering 101

Generally for us,the analysts to be able to understand the malware source code we must have special tools in order to unpack it's funcionallity.One of the newest and most commonly used such software is GHIDRA.GHIDRA is NSA's tool for reverse engineering.

When using ghidra it looks like this     


Generally in CTF's and industry a reverse engineer has to decrypt some encryption routine of create an interpeter/emulator for bypassing some sort of obfuscation.This skill is developed by practicing crackmes.Crackmes are cryptographic puzzles with the soley scope of generating a password in order to get to next level.


Simple crack me:

Before finishing this blog post i will solve as an introduction a crack me for the reader:

Here is the source code which i have prepared:

#include <stdio.h>

#include <string.h>

int main(int argc,char *argv[])

{

if(!strcmp("mama",argv[1]))

        {

printf("level bypassed,congrats!");

}

return 0;

}

compile it by using gcc like this : gcc name_of_source_code.c -o name_of_binary.
Now drag & drop in ghidra and it looks like this

on left we have assembly instructions and on right we have source code.
on simple analysis we can see there is a string comparisson if we provide the argument "mama" to the command line we bypass the level.Aweome lets try!


End 

That's a wrapp up

What the fuzz or how browser vulnerabilities are being found

 

Hello world today we are going to disscus browser bug bounty hunting also know as browser pwning.?Wait what ?

Yeah so in case you didn't know browser hacking was a thing since 2003,cause generally browsers are software,now software is writting in a specific programming language.Generally the browsers like chrome,firefox,edge are writting in C++ mainly and have some addition C.

What is fuzzing?

According to wikipedia:

"Fuzzing or fuzz testing is an automated software testing technique that involves providing invalid, unexpected, or random data as inputs to a computer program. The program is then monitored for exceptions such as crashes, failing built-in code assertions, or potential memory leaks. Typically, fuzzers are used to test programs that take structured inputs. This structure is specified, e.g., in a file format or protocol and distinguishes valid from invalid input. An effective fuzzer generates semi-valid inputs that are "valid enough" in that they are not directly rejected by the parser, but do create unexpected behaviors deeper in the program and are "invalid enough" to expose corner cases that have not been properly dealt with." -Wikiepdia(https://en.wikipedia.org/wiki/Fuzzing)

How many types of fuzzing exist there?

A lot.Oh and im not kidding there is supervised fuzzing,coveraged-based fuzzing,grammer fuzzing,dumb fuzzing,smart fuzzers,generational fuzzing and finally mutationally fuzzing.Now all of them fall under two great categories:dumb fuzzing,smart fuzzing.

Fuzzing Chrome:

Now before we starting attacking chrome blindy,a warining!Chrome has over 8.8GB in terms of base source code.Now in order for us to be able to find a potential crash we need to choose a component.Here is an example of jscore from edge browser.

Now you see i choose to fuzz the js engine behind a browser,you can choose other componenet.


Now the actuall fuzzing


Now you will not just write a dumb fuzzer like this one:


Now when we talk about big source codes we need to fuzz smart.We choose Grammer Based Fuzzing.

Quoting from mozila fuzzing page:"Grammar-based fuzzing is a fuzzing technique that uses a formal language grammar to define the structure of the data to be generated. These grammars are typically represented in plain-text and use a combination of symbols and constants to represent the data".

Now in the industry two most used fuzzers are dharma & domatto.We will use dharma.

Now dharma can be downloaded from this page:https://github.com/MozillaSecurity/dharma

How to use dharma


Actually it's not that hard since alll the heavylifting has been done by mozzing in terms of coding.Now for usage is "./dharma -grammars grammer -count number of samples to get generated -format format of file to be output -seed random number for more entropy -storage output folder".

Grammer

In terms of grammer we are supposed to have a valid input for the fuzzer to generate correct test cases.Lucky for us mozzila provides a grammer sample


Now if we run it we get this output

 

Now for making readers like easier i will give you a link to my grammer.It's under development so please know that some test cases might not be valid.https://github.com/SpiralBL0CK/custom-dharma-grammer-for-js-

End
Happy fuzzing!

Thursday, October 8, 2020

How i hacked bt telecom using an '95 trick

 SOooooo



About this,i have to first mention that this is just a legal.Now lets cut it to the chase


The processes is outlined below:


*OSINT USING Twitter in order to find the cve(i would call it more smthing cwe(common web vulnerability) since in this exploit is not involved any asm/c/bof/mem leak)

*OSINT USING SHODAN Engine in order to identify @ip vulnerable. 

*Exploit & Profit


First things first.


*OSINT USING Twitter in order to find the cve(i would call it more smthing cwe(common web vulnerability) since in this exploit is not involved any asm/c/bof/mem leak)

    Now anyone , does  cve2020-5902 ring a bell?In case not i will explain it to you.cve2020-5902 aka F5 IP RCE is a trivial exploit method caused by a trivial bug which is knows since '95.Now it happends that the whole internet buzzed out when this was disclosed. In case you did not know exploitdb is nothing compared to twitter.Generally people should have a twitter in case they just want to grab a lhf(low hanging fruit) in terms of bug bounty.It just so happend that i was following a reserach which just published a PoC(proof of concept) regards that cve.


* *OSINT USING SHODAN Engine in order to identify @ip vulnerable. 

Now this is the most trivial thing.Everyone use does some cyber should know about SHODAN. It's holly bible for us hackers.It does ip viking in order to do data mining in order to provide a bigger picture of vulnerable/open services around the internet.What i did was just build a simle query based around that cve.Let's break it down.The query used was:http.favicon.hash:-335242539 “3992”.The techniquck behind this is pretty old one here is a link which explains it :https://medium.com/@Asm0d3us/weaponizing-favicon-ico-for-bugbounties-osint-and-what-not-ace3c214e139.Now using that and entering that in the shodan search bar returned some ip which had the services running on them.


*Exploit & Profit

Once we knew our target ip it was a simple task as : python CVE-2020-5902.py @IP command to execute.In case you don't belive me here is are some screenshot.










*





padawan young welcome! Ahead pATH rough lies

 Hi,my name is Vlad and this will be my blog will focus mainly on Vr(Vulnerability Research) & Re(Reverse Engineering).I am a hacker.That's all that's needed to know about me.Want to know more about me? fine.I grew up in Romania,got bullied and found computers.G0t cyber bullied.Till one day until i said stop.Fast forward two years i won PwnTheBank@DefcampRO 2k18.Ok,Ok let's backtrack a little bit.... in thoese two years until Defcamp i had already been programming for two years at @CoderDojo where i even mentoreed.Fine want to know more about me. Ok but don't say i didn't warn you.Around 2016 i started highschool.Worst time of ma life. Baisically that got me in such a toxic environment that i turned black hat.So three years i was a black hat hacker.I was hitting any public institution in Romania and didn't care about what could happen.Aside that I was doing a lot of malware research and malware programming but thanks got that didn't got out of my home lab.Before defcamp breakup....Hit me so hard after the contest that it reseted me for good.Turned good side.Fast forward to this day been doing for two years bug bounty and vr.That's all in a very short tl;dr version about myself.

Moder Malware Development

SoOOO....... Malware Right...... Classic choice.Good one.So you choose to read this right,lets cut to the chase.


Nowdays malware got very advenced using 0day,different packers/differents algorithms used for encryption and obfuscation,even ai related for it in order to make it hard for the analyst to make their lives a hell.Fine,fine the industry also evolved.But ever thaught that with the upcoaming of web3.0 and distribuited apps the malware will become baisically invicible.Just think at this.Blockhain technology is baisically untracable.Now image if one uses a d-app as their c2 infrastructure or dump server as a malware componenet.NO PHYSICAL SERVERS REQUIRED!!Wthat does that mean?Means that nobody can turn it of :(.

libprotobuf&libfuzz Part 2.

 We just dissect the source code from this guy's repo:https://github.com/bruce30262/libprotobuf-mutator_fuzzing_learning we will use sam...