有二個步驟,先是開啟 Guest OS, 將它的剩餘磁碟空間清乾淨,這樣才有辦法壓縮
$ cat /dev/zero > zero.fill; sync; sleep 1; sync; rm -f zero.fill
可以看到普通使用者也可以進行,當然這是因為系統沒有設定 QUOTA, 建議可以保險點用 sudo 來進行,例如:
$ sudo cat /dev/zero > zero.fill; sync; sleep 1; sync; sudo rm -f zero.fill
再來就是在 HOST OS 中將它壓縮,一般網路上查到的作法分兩步,第一個就是「磁碟重整」,再來才是壓縮。但是經過實驗,可以合併成一步:
C:\Program Files (x86)\VMware\VMware Workstation\vmware-vdiskmanager -r D:\my.vmdk -t 0 D:\my-vmdk-shrink.vmdk
2013/10/17
2013/09/18
ubuntu amd64 編譯 x86.deb for kernel
2013/09/11
tar backup
tar 非常好用,很顯然的,因為太好用,常常都不知道怎麼用!怪哉。
寫過 daily update backup file 每日更新備份檔
寫過 daily update backup file 每日更新備份檔
也寫過 遠端備份? tar netcat
事實上要備份還有更多工具,我也沒有想要函蓋全部的企圖,這邊只是寫下我比較愛用的方式
LOCAL MACHINE
Copy A/ ==> B/
$ cd A; tar cf - . --exclude=.git | (cd B/ && tar xBf -)
REMOTE MACHINE
Copy A/ ==> M:B/
$ cd A; tar cf - . --exclude=.git | rsh M 'cd B/ && tar xBf -'
替代的有如 scp....
tar 的好處可以過濾掉某些不要的檔,如範例中的 .git
也可以只備份較新的檔,例如
tar --newer-mtime="`date -r REF-FILE`" cf - --exclude=.git | (cd B/ && tar xBF -)
2013/09/04
顯示隱藏裝置
唉,離不開 Windows...
話說,我的 skype 在 win8 中一直無法使用,今天突然好了~~~
不知道是否有人想要把『隱藏的裝置』刪掉的需求?譬如,某些廠商提供的工具,竟然限定 COM port 只能在 1-6....可是在插拔過程中,我的 COM Port 都跑到不知道多少去了,總之,絕不在1-6!!!!
那怎麼辦咧?一個辦法是拿程式來改,另一個是把沒插在電腦上的,也就是被隱藏起來的裝置移除~~請見 http://support.microsoft.com/kb/315539
剪貼一下上面網址的內容:
如果要解決這個問題,並在您按一下 [顯示隱藏裝置] 時顯示相關裝置:
話說,我的 skype 在 win8 中一直無法使用,今天突然好了~~~
不知道是否有人想要把『隱藏的裝置』刪掉的需求?譬如,某些廠商提供的工具,竟然限定 COM port 只能在 1-6....可是在插拔過程中,我的 COM Port 都跑到不知道多少去了,總之,絕不在1-6!!!!
那怎麼辦咧?一個辦法是拿程式來改,另一個是把沒插在電腦上的,也就是被隱藏起來的裝置移除~~請見 http://support.microsoft.com/kb/315539
剪貼一下上面網址的內容:
如果要解決這個問題,並在您按一下 [顯示隱藏裝置] 時顯示相關裝置:
- 按一下 [開始],依序指向 [程式集] 及 [附屬應用程式],再按一下 [命令提示字元]。
- 在命令提示字元中輸入下列命令,然後按下 ENTER:set devmgr_show_nonpresent_devices=1
- 在命令提示字元中輸入下列命令,然後按下 ENTER:start devmgmt.msc
- 疑難排解「裝置管理員」中的裝置和驅動程式。
注意:請先在裝置管理員的 [檢視] 功能表上按一下 [顯示隱藏裝置],以顯示未連線至電腦的裝置。 - 完成疑難排解後,關閉「裝置管理員」。
- 在命令提示字元中輸入 exit。
請注意,關閉命令提示字元視窗時,Window 會清除您在步驟 2 中所設定的 devmgr_show_nonpresent_devices=1 變數,避免隱藏連線的裝置在您按一下 [顯示隱藏裝置] 時顯現。
把影片轉成 DVD
老實說,我家算很落後,影片只有DVD Player, 其他格式很難在我家流通
小羊用 M$ Movie Maker 做出來的影片,他也會燒在光碟片中,可是就很難享受它的內容
這邊介紹兩個:
一個叫 格式工廠, 參考介紹如下
http://www.azofreeware.com/2008/10/formatfactory-155.html
一個叫 DVD Styler, 參考介紹如下
http://www.azofreeware.com/2010/02/dvdstyler-1801.html
小羊用 M$ Movie Maker 做出來的影片,他也會燒在光碟片中,可是就很難享受它的內容
這邊介紹兩個:
一個叫 格式工廠, 參考介紹如下
http://www.azofreeware.com/2008/10/formatfactory-155.html
一個叫 DVD Styler, 參考介紹如下
http://www.azofreeware.com/2010/02/dvdstyler-1801.html
2013/09/03
把開機光碟做在 usb disk 中 boot from usb
久沒用就忘了,還是寫下來的好
如果你想把某一片開機光碟放在隨身碟中,你會怎麼做?
有個簡單的工具: http://sourceforge.net/projects/unetbootin/files/latest/download
要教學步驟嗎?請見這兒
如果你想把某一片開機光碟放在隨身碟中,你會怎麼做?
有個簡單的工具: http://sourceforge.net/projects/unetbootin/files/latest/download
要教學步驟嗎?請見這兒
2013/08/13
ubuntu CPU loading 狀態列不見了
標題怪怪的啊,在 ubuntu 11.04 之後,因為換風格,無法加入 CPU LOADING, 其實加法如下:
1. 安裝 indicator-multiload
2. 叫出來
因為有人都做好影片了,直接觀看吧
http://www.youtube.com/watch?v=C8vMoSilwQo
1. 安裝 indicator-multiload
2. 叫出來
因為有人都做好影片了,直接觀看吧
http://www.youtube.com/watch?v=C8vMoSilwQo
2013/08/12
如何防止 visual studio 產生超大檔 .sdf
有兩個想法,一個是關閉 database, 一個是將它設在系統資料夾
前者見 http://stackoverflow.com/questions/8635219/how-to-prevent-visual-studio-2010-adding-large-sql-file-to-my-project-in-c
後者見 http://stackoverflow.com/questions/7706984/visual-studio-2010-c-project-remove-sdf-file
建議是用後者,這樣的話在原始碼目錄不會見到它,卻又可以在 visual studio 中使用它的好處
前者見 http://stackoverflow.com/questions/8635219/how-to-prevent-visual-studio-2010-adding-large-sql-file-to-my-project-in-c
後者見 http://stackoverflow.com/questions/7706984/visual-studio-2010-c-project-remove-sdf-file
建議是用後者,這樣的話在原始碼目錄不會見到它,卻又可以在 visual studio 中使用它的好處
2013/07/24
windows 修改 registry 的方法
程式化的方法就不說了,命令列的方式可以如下:
cmd /c reg add HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\system /v LocalAccountTokenFilterPolicy /t REG_DWORD /d 1 /f
或是匯入的
Cmd /c reg import c:\test.reg
當然,也可以用檔案總管來執行 .reg 檔
2013/07/22
windows undocumented secret 不傳之秘
請參考這兒....話說,怎麼會跑回來看這種秘技?常常灌了不知道什麼東西,讓瀏覽器動作怪怪的,也許在底下可以找到原因!
1. 當使用者登入系統時,在這個機碼(key)下的的程式或Script會被自動執行起來:
HKLM\Software\Microsoft\Windows\CurrentVersion\Policies\Explorer\Run\
HKCU\Software\Microsoft\Windows\CurrentVersion\Policies\Explorer\Run\
HKLM\Software\Microsoft\Windows\CurrentVersion\Run\
HKCU\Software\Microsoft\Windows\CurrentVersion\Run\
HKLM\Software\Microsoft\Windows\CurrentVersion\RunOnce\
HKCU\Software\Microsoft\Windows\CurrentVersion\RunOnce\
HKLM\Software\Microsoft\Windows\CurrentVersion\RunOnce\Setup\
HKLM\Software\Microsoft\Windows\CurrentVersion\RunOnceEx\
HKLM\Software\Microsoft\Windows\CurrentVersion\RunServices\
HKLM\Software\Microsoft\Windows\CurrentVersion\RunServicesOnce\
HKCU\Software\Microsoft\Windows NT\CurrentVersion\Windows\load\
HKCU\Software\Microsoft\Windows NT\CurrentVersion\Windows\run
HKLM\Software\Policies\Microsoft\Windows\System\Scripts\
HKCU\Software\Policies\Microsoft\Windows\System\Scripts
參考:
How to Modify the List of Programs that Run When You Start Windows XP (http://support.microsoft.com/kb/314488).
A definition of the Run keys in the Windows XP registry (http://support.microsoft.com/kb/314866/EN-US/).
INFO: Run, RunOnce, RunServices, RunServicesOnce and Startup (http://support.microsoft.com/kb/179365/EN-US/).
Definition of the RunOnce Keys in the Registry (http://support.microsoft.com/kb/137367).
Description of the RunOnceEx Registry Key (http://support.microsoft.com/kb/310593/EN-US/).
Programs Automatically Start When User Logs on to Windows (http://support.microsoft.com/kb/147369).
Script Policy Is Not Run When a Slow Link Is Detected (http://support.microsoft.com/default.aspx?scid=kb;en-us;328991).
To assign user logoff scripts (http://www.microsoft.com/resources/documentation/windows/xp/all/proddocs/en-us/gptext_logoffscripts.mspx?mfr=true).
2. 當IE啟動時,在這個機碼下的元件(in-process COM components)每次都會被IE載入,這就是在IE上看到的工具列:
HKLM\Software\Microsoft\Windows\CurrentVersion\Explorer\Browser Helper Objects\
參考:
How to disable third-party tool bands and Browser Helper Objects (http://support.microsoft.com/default.aspx?scid=kb;en-us;298931).
Browser Helper Objects: The Browser the Way You Want It (http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnwebgen/html/bho.asp).
3. 預設值為'"%1" %*'(沒有單引號)。有些惡意程式會把它修改為'"FileName "%1" %*',當執行可執行檔(.exe)時,檔案"FileName"也會被執行起來:
HKLM\Software\Classes\exefile\shell\open\command\
HKEY_CLASSES_ROOT\vbsfile\shell\open\command\ (差別在於它是Visual Basic Script檔(.vbs))
HKEY_CLASSES_ROOT\vbefile\shell\open\command\ (差別在於它是編碼過的Visual Basic Script檔(.vbe))
HKEY_CLASSES_ROOT\jsfile\shell\open\command\ (差別在於它是JavaScript檔(.js))
HKEY_CLASSES_ROOT\jsefile\shell\open\command\ (差別在於它是編碼過的JavaScript檔(.jse))
HKEY_CLASSES_ROOT\wshfile\shell\open\command\ (差別在於它是Windows Scripting Host檔(.wsh))
HKEY_CLASSES_ROOT\wsffile\shell\open\command\ (差別在於它是Windows Scripting File檔(.wsf))
HKEY_CLASSES_ROOT\comfile\shell\open\command\ (差別在於它是COM檔(.com))
HKEY_CLASSES_ROOT\batfile\shell\open\command\ (差別在於它是批次檔(.bat))
HKEY_CLASSES_ROOT\scrfile\shell\open\command\ (差別在於它是螢幕保護檔(.scr))
HKEY_CLASSES_ROOT\piffile\shell\open\command\ (差別在於它是Portable Interchange Format檔(.bat))
參考:
You Are Unable to Start a Program with an .exe File Extension (http://support.microsoft.com/default.aspx?scid=kb;en-us;310585).
You receive an error message when you try to start a program that has an .exe file name extension (http://support.microsoft.com/kb/837334/en-us).
4. 每次啟動CMD.exe時,在這個機碼下的命令會被執行:
HKLM\Software\Microsoft\Command Processor\AutoRun\
HKCU\Software\Microsoft\Command Processor\AutoRun\
參考:
WORM_SWEN.A (http://www.trendmicro.com/vinfo/virusencyclo/default5.asp?VName=WORM%5FSWEN%2EA&VSect=T)
Cmd (http://www.microsoft.com/resources/documentation/windows/xp/all/proddocs/en-us/cmd.mspx?mfr=true).
AutoRun (http://www.microsoft.com/resources/documentation/Windows/2000/server/reskit/en-us/Default.asp?url=/resources/documentation/Windows/2000/server/reskit/en-us/regentry/942.asp).
5. 在這機碼下的CLSID會對應到HKLM\Software\Classes\CLSID\{GUID}\InProcServer。每當IE啟動時,它們會被IE載入:
HKLM\Software\Microsoft\Windows\CurrentVersion\ShellServiceObjectDelayLoad\
HKCU\Software\Microsoft\Windows\CurrentVersion\ShellServiceObjectDelayLoad\
參考:
TROJ_YABE.H (http://www.trendmicro.com/vinfo/virusencyclo/default5.asp?VName=TROJ_YABE.H&VSect=Sn).
Download.Ject Payload Detection and Removal Tool (http://support.microsoft.com/default.aspx?scid=kb;en-us;873018).
6. 可以自訂不同的使用者介面:
HKCU\Software\Microsoft\Windows\CurrentVersion\Policies\System\Shell\
參考:
Shell (http://www.microsoft.com/resources/documentation/Windows/2000/server/reskit/en-us/Default.asp?url=/resources/documentation/Windows/2000/server/reskit/en-us/regentry/93488.asp).
7. 包含被允許的Shell Extensions表列:
HKLM\Software\Microsoft\Windows\CurrentVersion\Shell Extensions\Approved\
8. 當使用者登入系統時,在這個機碼裡的DLLs會被Windows-based應用程式載入(DLL Injection的一種方法):
HKLM\Software\Microsoft\Windows NT\CurrentVersion\Windows\AppInit_DLLs
參考:
Working with the AppInit_DLLs registry value (http://support.microsoft.com/default.aspx?scid=kb;en-us;197571).
9. 當Windows NT會執行標準的GINA DLL(MSGina.d)。當GinaDLL機碼存在時,在這機碼下面的DLL會被Winlogon在載入:
HKLM\Software\Microsoft\Windows NT\CurrentVersion\Winlogon\GinaDLL\
參考:
Windows NT loads and executes the standard Microsoft GINA DLL (MSGina.dll). If the GinaDLL key value is present, it must contain the name of a GINA DLL, which Winlogon will load and use.
Loading and Running a GINA DLL (http://msdn.microsoft.com/library/default.asp?url=/library/en-us/secauthn/security/loading_and_running_a_gina_dll.asp).
10. 這個機碼可以更改原來的SHell(explorer.exe)且在這機碼下的執行檔會被Userinit.exe啟動:
HKLM\Software\Microsoft\Windows NT\CurrentVersion\Winlogon\Shell
HKCU\Software\Microsoft\Windows NT\CurrentVersion\Winlogon\Shell
參考:
Shells Other Than Explorer.exe Replaced on Installation or Upgrade (http://support.microsoft.com/default.aspx?scid=kb;en-us;228309).
11. 在這機碼下的程式會在System Mode被啟動:
HKLM\Software\Microsoft\Windows NT\CurrentVersion\Winlogon\System
參考:
System (http://www.microsoft.com/resources/documentation/Windows/2000/server/reskit/en-us/Default.asp?url=/resources/documentation/Windows/2000/server/reskit/en-us/regentry/58543.asp).
12. 可以定義系統所使用的工作管理員:
HKLM\Software\Microsoft\Windows NT\CurrentVersion\Winlogon\TaskMan
參考:
TaskMan (http://www.microsoft.com/resources/documentation/Windows/2000/server/reskit/en-us/Default.asp?url=/resources/documentation/Windows/2000/server/reskit/en-us/regentry/58543.asp).
13. 當使用者登入系統時,在這機碼下的程式會被Winlogon執行。預設是Userinit.exe:
HKLM\Software\Microsoft\Windows NT\CurrentVersion\Winlogon\UserInit
14. 在這機碼下的DLLs會接收和處理由Winlogon產生的事件(event):
HKLM\Software\Microsoft\Windows NT\CurrentVersion\Winlogon\Notify\
參考:
Winlogon Notification Packages (http://msdn.microsoft.com/library/default.asp?url=/library/en-us/secauthn/security/registry_entries.asp).
15. 當系統啟動時,在這個機碼裡的程式會被執行:
HKLM\System\CurrentControlSet\Control\Session Manager\BootExecute
參考:
BootExecute (http://www.microsoft.com/resources/documentation/Windows/2000/server/reskit/en-us/Default.asp?url=/resources/documentation/Windows/2000/server/reskit/en-us/regentry/46697.asp).
16. 在這機碼下的服務,大部份會以LocalSystem的權限啟動:
HKLM\System\CurrentControlSet\Services\
17. 微軟使用這個機碼來設定已經安裝的視窗元件(Windows component):
HKLM\Software\Microsoft\Active Setup\Installed Components\
參考:
TROJ_SMALL.AZX (http://www.trendmicro.com/vinfo/virusencyclo/default5.asp?VName=TROJ%5FSMALL%2EAZX&VSect=T).
Backdoor.Plux (http://securityresponse.symantec.com/avcenter/venc/data/backdoor.plux.html).
Monitoring of the Active Setup Registry Key (http://www.greatis.com/webhelp/regrunhelp.htm#regrun___detailed_instructions/start_control/active_setup_registry_key.htm).
18. 這個機碼記錄現行使用者(Current User)的啟動目錄(「開始」功能表=>程式集=>啟動,亦即,%USERPROFILE%\「開始」功能表\程式集\啟動):
HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\User Shell Folders\Startup
HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\Shell Folders\Startup (如果上一列機碼不存在,它會用這個機碼)
HKLM\Software\Microsoft\Windows\CurrentVersion\explorer\User Shell Folders\Common Startup (這個機碼記錄所有使用者的啟動目錄(「開始」功能表=>程式集=>啟動,亦即,%ALLUSERSPROFILE%\「開始」功能表\程式集\啟動))
HKLM\Software\Microsoft\Windows\CurrentVersion\Explorer\Shell Folders\Common Startup (如果上一列機碼不存在,它會用這個機碼)
19. 在這機碼下的子機碼記載每個程式的路徑和完整的執行路徑名稱:
HKLM\Software\Microsoft\Windows\CurrentVersion\App Paths\
20. 這是用來檢查應用程式的問題,但惡意程式會利用它,以達到執行的目的:
HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Image File Execution Options\
參考:
Inside 'Image File Execution Options' debugging (http://blogs.msdn.com/greggm/archive/2005/02/21/377663.aspx).
How to Enable Kerberos Debugging in Windows 2000 (http://support.microsoft.com/default.aspx?scid=kb;en-us;892894;http://support.microsoft.com/default.aspx?scid=kb;en-us;216052).
21. 在這機碼下COM Objects會記錄執行的命令。預設值是shell32.dll:
HKLM\Software\Microsoft\Windows\CurrentVersion\Explorer\ShellExecuteHooks\
參考:
Logging the Shell Activity (http://www.codeguru.com/Cpp/COM-Tech/shell/article.php/c4515/#more).
Windows Core (http://www.greatis.com/webhelp/regrun___detailed_instructions/start_control/windows_core.htm).
Creating a shell extension with C# (http://www.codeproject.com/csharp/dateparser.asp).
* Folder Autostart Locations
1. %USERPROFILE%\「開始」功能表\程式集\啟動
2. %ALLUSERSPROFILE%\「開始」功能表\程式集\啟動
3. %SystemRoot\Tasks (排程工作的目錄)
* File AutoStart Locations
1. %SystemDrive%\explorer.exe:EXPLORER.EXE是Windows的檔案總管程式,正常位置是在%SystemRoot %目錄內。某些人會使用的一個技巧,就是在C:\目錄底下產生一個同樣取名為explorer.exe。當Windows在開機時,並未指定 explorer.exe應該在哪個目錄底下,所以,開機時會從根目錄開始尋找該檔案來執行。
2. %SystemDrive%\autoexec.bat
參考:
http://en.wikipedia.org/wiki/AUTOEXEC.BAT
3. %SystemDrive%\config.sys
參考:
http://en.wikipedia.org/wiki/CONFIG.SYS
4. wininit.ini: 是Windows在開機時用來預先載入某些應用程式的方法。
舉例說明:
shell=explorer.exe virusfile.exe
5. winstart.bat
6. win.ini: 是載入系統設定,例如驅動程式、桌布畫面等等。
舉例說明:
load=virusfile.exe
run=virusfile.exe
7. hosts
參考:
http://en.wikipedia.org/wiki/Hosts
1. 當使用者登入系統時,在這個機碼(key)下的的程式或Script會被自動執行起來:
HKLM\Software\Microsoft\Windows\CurrentVersion\Policies\Explorer\Run\
HKCU\Software\Microsoft\Windows\CurrentVersion\Policies\Explorer\Run\
HKLM\Software\Microsoft\Windows\CurrentVersion\Run\
HKCU\Software\Microsoft\Windows\CurrentVersion\Run\
HKLM\Software\Microsoft\Windows\CurrentVersion\RunOnce\
HKCU\Software\Microsoft\Windows\CurrentVersion\RunOnce\
HKLM\Software\Microsoft\Windows\CurrentVersion\RunOnce\Setup\
HKLM\Software\Microsoft\Windows\CurrentVersion\RunOnceEx\
HKLM\Software\Microsoft\Windows\CurrentVersion\RunServices\
HKLM\Software\Microsoft\Windows\CurrentVersion\RunServicesOnce\
HKCU\Software\Microsoft\Windows NT\CurrentVersion\Windows\load\
HKCU\Software\Microsoft\Windows NT\CurrentVersion\Windows\run
HKLM\Software\Policies\Microsoft\Windows\System\Scripts\
HKCU\Software\Policies\Microsoft\Windows\System\Scripts
參考:
How to Modify the List of Programs that Run When You Start Windows XP (http://support.microsoft.com/kb/314488).
A definition of the Run keys in the Windows XP registry (http://support.microsoft.com/kb/314866/EN-US/).
INFO: Run, RunOnce, RunServices, RunServicesOnce and Startup (http://support.microsoft.com/kb/179365/EN-US/).
Definition of the RunOnce Keys in the Registry (http://support.microsoft.com/kb/137367).
Description of the RunOnceEx Registry Key (http://support.microsoft.com/kb/310593/EN-US/).
Programs Automatically Start When User Logs on to Windows (http://support.microsoft.com/kb/147369).
Script Policy Is Not Run When a Slow Link Is Detected (http://support.microsoft.com/default.aspx?scid=kb;en-us;328991).
To assign user logoff scripts (http://www.microsoft.com/resources/documentation/windows/xp/all/proddocs/en-us/gptext_logoffscripts.mspx?mfr=true).
2. 當IE啟動時,在這個機碼下的元件(in-process COM components)每次都會被IE載入,這就是在IE上看到的工具列:
HKLM\Software\Microsoft\Windows\CurrentVersion\Explorer\Browser Helper Objects\
參考:
How to disable third-party tool bands and Browser Helper Objects (http://support.microsoft.com/default.aspx?scid=kb;en-us;298931).
Browser Helper Objects: The Browser the Way You Want It (http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnwebgen/html/bho.asp).
3. 預設值為'"%1" %*'(沒有單引號)。有些惡意程式會把它修改為'"FileName "%1" %*',當執行可執行檔(.exe)時,檔案"FileName"也會被執行起來:
HKLM\Software\Classes\exefile\shell\open\command\
HKEY_CLASSES_ROOT\vbsfile\shell\open\command\ (差別在於它是Visual Basic Script檔(.vbs))
HKEY_CLASSES_ROOT\vbefile\shell\open\command\ (差別在於它是編碼過的Visual Basic Script檔(.vbe))
HKEY_CLASSES_ROOT\jsfile\shell\open\command\ (差別在於它是JavaScript檔(.js))
HKEY_CLASSES_ROOT\jsefile\shell\open\command\ (差別在於它是編碼過的JavaScript檔(.jse))
HKEY_CLASSES_ROOT\wshfile\shell\open\command\ (差別在於它是Windows Scripting Host檔(.wsh))
HKEY_CLASSES_ROOT\wsffile\shell\open\command\ (差別在於它是Windows Scripting File檔(.wsf))
HKEY_CLASSES_ROOT\comfile\shell\open\command\ (差別在於它是COM檔(.com))
HKEY_CLASSES_ROOT\batfile\shell\open\command\ (差別在於它是批次檔(.bat))
HKEY_CLASSES_ROOT\scrfile\shell\open\command\ (差別在於它是螢幕保護檔(.scr))
HKEY_CLASSES_ROOT\piffile\shell\open\command\ (差別在於它是Portable Interchange Format檔(.bat))
參考:
You Are Unable to Start a Program with an .exe File Extension (http://support.microsoft.com/default.aspx?scid=kb;en-us;310585).
You receive an error message when you try to start a program that has an .exe file name extension (http://support.microsoft.com/kb/837334/en-us).
4. 每次啟動CMD.exe時,在這個機碼下的命令會被執行:
HKLM\Software\Microsoft\Command Processor\AutoRun\
HKCU\Software\Microsoft\Command Processor\AutoRun\
參考:
WORM_SWEN.A (http://www.trendmicro.com/vinfo/virusencyclo/default5.asp?VName=WORM%5FSWEN%2EA&VSect=T)
Cmd (http://www.microsoft.com/resources/documentation/windows/xp/all/proddocs/en-us/cmd.mspx?mfr=true).
AutoRun (http://www.microsoft.com/resources/documentation/Windows/2000/server/reskit/en-us/Default.asp?url=/resources/documentation/Windows/2000/server/reskit/en-us/regentry/942.asp).
5. 在這機碼下的CLSID會對應到HKLM\Software\Classes\CLSID\{GUID}\InProcServer。每當IE啟動時,它們會被IE載入:
HKLM\Software\Microsoft\Windows\CurrentVersion\ShellServiceObjectDelayLoad\
HKCU\Software\Microsoft\Windows\CurrentVersion\ShellServiceObjectDelayLoad\
參考:
TROJ_YABE.H (http://www.trendmicro.com/vinfo/virusencyclo/default5.asp?VName=TROJ_YABE.H&VSect=Sn).
Download.Ject Payload Detection and Removal Tool (http://support.microsoft.com/default.aspx?scid=kb;en-us;873018).
6. 可以自訂不同的使用者介面:
HKCU\Software\Microsoft\Windows\CurrentVersion\Policies\System\Shell\
參考:
Shell (http://www.microsoft.com/resources/documentation/Windows/2000/server/reskit/en-us/Default.asp?url=/resources/documentation/Windows/2000/server/reskit/en-us/regentry/93488.asp).
7. 包含被允許的Shell Extensions表列:
HKLM\Software\Microsoft\Windows\CurrentVersion\Shell Extensions\Approved\
8. 當使用者登入系統時,在這個機碼裡的DLLs會被Windows-based應用程式載入(DLL Injection的一種方法):
HKLM\Software\Microsoft\Windows NT\CurrentVersion\Windows\AppInit_DLLs
參考:
Working with the AppInit_DLLs registry value (http://support.microsoft.com/default.aspx?scid=kb;en-us;197571).
9. 當Windows NT會執行標準的GINA DLL(MSGina.d)。當GinaDLL機碼存在時,在這機碼下面的DLL會被Winlogon在載入:
HKLM\Software\Microsoft\Windows NT\CurrentVersion\Winlogon\GinaDLL\
參考:
Windows NT loads and executes the standard Microsoft GINA DLL (MSGina.dll). If the GinaDLL key value is present, it must contain the name of a GINA DLL, which Winlogon will load and use.
Loading and Running a GINA DLL (http://msdn.microsoft.com/library/default.asp?url=/library/en-us/secauthn/security/loading_and_running_a_gina_dll.asp).
10. 這個機碼可以更改原來的SHell(explorer.exe)且在這機碼下的執行檔會被Userinit.exe啟動:
HKLM\Software\Microsoft\Windows NT\CurrentVersion\Winlogon\Shell
HKCU\Software\Microsoft\Windows NT\CurrentVersion\Winlogon\Shell
參考:
Shells Other Than Explorer.exe Replaced on Installation or Upgrade (http://support.microsoft.com/default.aspx?scid=kb;en-us;228309).
11. 在這機碼下的程式會在System Mode被啟動:
HKLM\Software\Microsoft\Windows NT\CurrentVersion\Winlogon\System
參考:
System (http://www.microsoft.com/resources/documentation/Windows/2000/server/reskit/en-us/Default.asp?url=/resources/documentation/Windows/2000/server/reskit/en-us/regentry/58543.asp).
12. 可以定義系統所使用的工作管理員:
HKLM\Software\Microsoft\Windows NT\CurrentVersion\Winlogon\TaskMan
參考:
TaskMan (http://www.microsoft.com/resources/documentation/Windows/2000/server/reskit/en-us/Default.asp?url=/resources/documentation/Windows/2000/server/reskit/en-us/regentry/58543.asp).
13. 當使用者登入系統時,在這機碼下的程式會被Winlogon執行。預設是Userinit.exe:
HKLM\Software\Microsoft\Windows NT\CurrentVersion\Winlogon\UserInit
14. 在這機碼下的DLLs會接收和處理由Winlogon產生的事件(event):
HKLM\Software\Microsoft\Windows NT\CurrentVersion\Winlogon\Notify\
參考:
Winlogon Notification Packages (http://msdn.microsoft.com/library/default.asp?url=/library/en-us/secauthn/security/registry_entries.asp).
15. 當系統啟動時,在這個機碼裡的程式會被執行:
HKLM\System\CurrentControlSet\Control\Session Manager\BootExecute
參考:
BootExecute (http://www.microsoft.com/resources/documentation/Windows/2000/server/reskit/en-us/Default.asp?url=/resources/documentation/Windows/2000/server/reskit/en-us/regentry/46697.asp).
16. 在這機碼下的服務,大部份會以LocalSystem的權限啟動:
HKLM\System\CurrentControlSet\Services\
17. 微軟使用這個機碼來設定已經安裝的視窗元件(Windows component):
HKLM\Software\Microsoft\Active Setup\Installed Components\
參考:
TROJ_SMALL.AZX (http://www.trendmicro.com/vinfo/virusencyclo/default5.asp?VName=TROJ%5FSMALL%2EAZX&VSect=T).
Backdoor.Plux (http://securityresponse.symantec.com/avcenter/venc/data/backdoor.plux.html).
Monitoring of the Active Setup Registry Key (http://www.greatis.com/webhelp/regrunhelp.htm#regrun___detailed_instructions/start_control/active_setup_registry_key.htm).
18. 這個機碼記錄現行使用者(Current User)的啟動目錄(「開始」功能表=>程式集=>啟動,亦即,%USERPROFILE%\「開始」功能表\程式集\啟動):
HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\User Shell Folders\Startup
HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\Shell Folders\Startup (如果上一列機碼不存在,它會用這個機碼)
HKLM\Software\Microsoft\Windows\CurrentVersion\explorer\User Shell Folders\Common Startup (這個機碼記錄所有使用者的啟動目錄(「開始」功能表=>程式集=>啟動,亦即,%ALLUSERSPROFILE%\「開始」功能表\程式集\啟動))
HKLM\Software\Microsoft\Windows\CurrentVersion\Explorer\Shell Folders\Common Startup (如果上一列機碼不存在,它會用這個機碼)
19. 在這機碼下的子機碼記載每個程式的路徑和完整的執行路徑名稱:
HKLM\Software\Microsoft\Windows\CurrentVersion\App Paths\
20. 這是用來檢查應用程式的問題,但惡意程式會利用它,以達到執行的目的:
HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Image File Execution Options\
參考:
Inside 'Image File Execution Options' debugging (http://blogs.msdn.com/greggm/archive/2005/02/21/377663.aspx).
How to Enable Kerberos Debugging in Windows 2000 (http://support.microsoft.com/default.aspx?scid=kb;en-us;892894;http://support.microsoft.com/default.aspx?scid=kb;en-us;216052).
21. 在這機碼下COM Objects會記錄執行的命令。預設值是shell32.dll:
HKLM\Software\Microsoft\Windows\CurrentVersion\Explorer\ShellExecuteHooks\
參考:
Logging the Shell Activity (http://www.codeguru.com/Cpp/COM-Tech/shell/article.php/c4515/#more).
Windows Core (http://www.greatis.com/webhelp/regrun___detailed_instructions/start_control/windows_core.htm).
Creating a shell extension with C# (http://www.codeproject.com/csharp/dateparser.asp).
* Folder Autostart Locations
1. %USERPROFILE%\「開始」功能表\程式集\啟動
2. %ALLUSERSPROFILE%\「開始」功能表\程式集\啟動
3. %SystemRoot\Tasks (排程工作的目錄)
* File AutoStart Locations
1. %SystemDrive%\explorer.exe:EXPLORER.EXE是Windows的檔案總管程式,正常位置是在%SystemRoot %目錄內。某些人會使用的一個技巧,就是在C:\目錄底下產生一個同樣取名為explorer.exe。當Windows在開機時,並未指定 explorer.exe應該在哪個目錄底下,所以,開機時會從根目錄開始尋找該檔案來執行。
2. %SystemDrive%\autoexec.bat
參考:
http://en.wikipedia.org/wiki/AUTOEXEC.BAT
3. %SystemDrive%\config.sys
參考:
http://en.wikipedia.org/wiki/CONFIG.SYS
4. wininit.ini: 是Windows在開機時用來預先載入某些應用程式的方法。
舉例說明:
shell=explorer.exe virusfile.exe
5. winstart.bat
6. win.ini: 是載入系統設定,例如驅動程式、桌布畫面等等。
舉例說明:
load=virusfile.exe
run=virusfile.exe
7. hosts
參考:
http://en.wikipedia.org/wiki/Hosts
2013/07/12
windows 8 登入馬上用傳統桌面
出處請見這兒
簡單講就是,利用 schtasks 也就是 Windows 的排程,讓它在登入時執行以下程式,將之存成 C:\ShowDesktop.scf
[Shell]
Command=2
IconFile=Explorer.exe,3
[Taskbar]
Command=ToggleDesktop
幾個注意事項:
1. trigger 在登入時
2. 在條件中,取消勾選「只有在電腦是使用 AC 電源時才啟動」
2013/07/02
利用 curl 來存取 appengine
這邊有一篇不錯的文章: Authenticating Google App Engine apps using curl
我以目前正在寫的 device-mgm 為例, 密碼假設是 Iamwade,其餘都沒改:
Step 1:
Getting auth key:
PS2: service 是 "ah", 這一點是我一直沒試出來的部份, 另外就是 source=device-mgm 是與 APP ID 一樣
PS3: 因為我一直都是用 gmail account, 所以 accountType 選 GOOGLE
Step 2:
Getting application cookie:
PS2: 會把 cookie 存到 cookiefile 中,這個檔跟原文作者貼的格式不一樣, 所以後面的命令要修
Step 3:
Calling our application service, getAllData:
PS1: 我是直接取最後一個非空白行,然後取第7欄,那就是 ACSID
PS2: 同一個應用(device-mgm)的不同服務,事實上也都可以適用,例如底下是 query:
curl -f -s -H "Cookie: ACSID=`awk '/./{line=$0} END{print line}' cookiefile | cut -f7`" http://device-mgm.appspot.com/query
我以目前正在寫的 device-mgm 為例, 密碼假設是 Iamwade,其餘都沒改:
Step 1:
Getting auth key:
curl -f -s --output myAuthFile.txt -d Email=wade.fs@gmail.com -d Passwd=Iamwade -d accountType=GOOGLE -d service=ah -d source=device-mgm https://www.google.com/accounts/ClientLoginPS1: 用 -d 或是用 --data-urlencode 都行,因為沒特殊字元, 若密碼有特殊字元,就要把 Passwd 那段改成 --data-urlencode Passwd=YOUR_PASSWORD
PS2: service 是 "ah", 這一點是我一直沒試出來的部份, 另外就是 source=device-mgm 是與 APP ID 一樣
PS3: 因為我一直都是用 gmail account, 所以 accountType 選 GOOGLE
Step 2:
Getting application cookie:
curl -c cookiefile "http://device-mgm.appspot.com/_ah/login?auth=`cat myAuthFile.txt | grep ^Auth= | cut -d= -f2`" > /dev/nullPS1: 若沒有導向 > /dev/null 會看到類似錯誤訊息,可以忽略
PS2: 會把 cookie 存到 cookiefile 中,這個檔跟原文作者貼的格式不一樣, 所以後面的命令要修
Step 3:
Calling our application service, getAllData:
curl -f -s -H "Cookie: ACSID=`awk '/./{line=$0} END{print line}' cookiefile | cut -f7`" http://device-mgm.appspot.com/help
PS1: 我是直接取最後一個非空白行,然後取第7欄,那就是 ACSID
PS2: 同一個應用(device-mgm)的不同服務,事實上也都可以適用,例如底下是 query:
curl -f -s -H "Cookie: ACSID=`awk '/./{line=$0} END{print line}' cookiefile | cut -f7`" http://device-mgm.appspot.com/query
利用 curl 上傳檔案到 google drive
看到一篇 google.sh 的文章討論「利用 curl 上傳檔案到 google drive」這件事,裡面的回應改良了 script 的寫法,把帳號密碼跟 script 分開是比較優良的寫法,因此在此跟大家分享。
該回應中的 script 有點 bug, 修正如下:
===============================================
if [ ! -f $1 ];then
echo "please provide a file in arg"
exit -1
fi
creditFile=~/bin/credits.ini
if [ ! -f $creditFile ];then
echo "please fill $creditFile (file has just been created)"
echo "username=$login
password=$pass">$creditFile
exit -1
fi
file="$1"
browser="Mozilla/5.0 (X11; Ubuntu; Linux i686; rv:13.0) Gecko/20100101 Firefox/13.0.1"
. $creditFile
accountype="GOOGLE" #gooApps = HOSTED , gmail=GOOGLE
mime_type=`file -b --mime-type $file`
/usr/bin/curl -v --data-urlencode Email=$username --data-urlencode Passwd=$password -d accountType=$accountype -d service=writely -d source=cURL "https://www.google.com/accounts/ClientLogin" > /tmp/login.txt
token=`cat /tmp/login.txt | grep Auth | cut -d \= -f 2`
uploadlink=`/usr/bin/curl -Sv -k --request POST -H "Content-Length: 0" -H "Authorization: GoogleLogin auth=${token}" -H "GData-Version: 3.0" -H "Content-Type: $mime_type" -H "Slug: $file" "https://docs.google.com/feeds/upload/create-session/default/private/full?convert=false" -D /dev/stdout | grep "Location:" | sed s/"Location: "//`
/usr/bin/curl -Sv -k --request POST --data-binary "@$file" -H "Authorization: GoogleLogin auth=${token}" -H "GData-Version: 3.0" -H "Content-Type: $mime_type" -H "Slug: $file" "$uploadlink" > /tmp/google-log.upload.txt
============
第一次執行時,會產生 credits.ini 然後就離開了, 請自行填滿它,存檔後再次執行即可,用法如下:
google-drive.sh UPLOAD.FILE
譬如:
google-drive.sh google-drive.sh # 把自己上傳
該回應中的 script 有點 bug, 修正如下:
===============================================
if [ ! -f $1 ];then
echo "please provide a file in arg"
exit -1
fi
creditFile=~/bin/credits.ini
if [ ! -f $creditFile ];then
echo "please fill $creditFile (file has just been created)"
echo "username=$login
password=$pass">$creditFile
exit -1
fi
file="$1"
browser="Mozilla/5.0 (X11; Ubuntu; Linux i686; rv:13.0) Gecko/20100101 Firefox/13.0.1"
. $creditFile
accountype="GOOGLE" #gooApps = HOSTED , gmail=GOOGLE
mime_type=`file -b --mime-type $file`
/usr/bin/curl -v --data-urlencode Email=$username --data-urlencode Passwd=$password -d accountType=$accountype -d service=writely -d source=cURL "https://www.google.com/accounts/ClientLogin" > /tmp/login.txt
token=`cat /tmp/login.txt | grep Auth | cut -d \= -f 2`
uploadlink=`/usr/bin/curl -Sv -k --request POST -H "Content-Length: 0" -H "Authorization: GoogleLogin auth=${token}" -H "GData-Version: 3.0" -H "Content-Type: $mime_type" -H "Slug: $file" "https://docs.google.com/feeds/upload/create-session/default/private/full?convert=false" -D /dev/stdout | grep "Location:" | sed s/"Location: "//`
/usr/bin/curl -Sv -k --request POST --data-binary "@$file" -H "Authorization: GoogleLogin auth=${token}" -H "GData-Version: 3.0" -H "Content-Type: $mime_type" -H "Slug: $file" "$uploadlink" > /tmp/google-log.upload.txt
============
第一次執行時,會產生 credits.ini 然後就離開了, 請自行填滿它,存檔後再次執行即可,用法如下:
google-drive.sh UPLOAD.FILE
譬如:
google-drive.sh google-drive.sh # 把自己上傳
2013/06/21
VPN 測試專用
1. 從『設定』
2. 找到『無線網路』下方的『更多內容...』
3. VPN
4. 右上角的『十』
5. 設定 VPN:
1) 名稱: 自選
2) 類型: L2TP/IPSec PSK
3) 伺服器: t.chqvpn.com
4) IPSec 預先共用金鑰: 123456
6. 點選剛剛「自選」的連線.....
7. 會跳出視窗需要輸入:
1) 使用者名稱: rainbowvpn
2) 密碼: 10fenzhong
3) 勾選『儲存帳戶資訊』
2013/04/19
在 google drive 的試算表中插入 url
有沒有用心真的是很重要!
一直以來就有個需求,就是在試算表中的文字插入 url, 但是不會做,從功能表也看不到,以為做不到,其實是沒有用心學!
google 有篇說明試算表怎麼插入 url就有說明。
昨晚還在跟小羊講,學校在很多年前都免費幫微軟教學、打廣告,甚至變成推銷商。google drive 就算有很強的功能,真正要落實還是很難。這篇就當小小的引子
一直以來就有個需求,就是在試算表中的文字插入 url, 但是不會做,從功能表也看不到,以為做不到,其實是沒有用心學!
google 有篇說明試算表怎麼插入 url就有說明。
昨晚還在跟小羊講,學校在很多年前都免費幫微軟教學、打廣告,甚至變成推銷商。google drive 就算有很強的功能,真正要落實還是很難。這篇就當小小的引子
2013/02/19
2012/06/29
virtualbox how to shrink vdi 檔如何壓縮?
明明已經把系統空間空出來了,可是 vdi 檔卻是愈長愈大,之前也不是很在意,主要是這次是要給別人用的,檔案太大不方便傳輸。要把明明系統不大,但是 vdi 檔卻相對非常大的檔縮小是可能的,會發生這樣的事主要是我在機器裡面編譯整個 android, 事後雖然 make clean 仍然不會因此變小,甚至還有加檔的話,vdi 檔仍然繼續變大....
1. guest 系統裡面請安裝 zerofree, 它不大,作用就是把已經刪除的 inode 資料清空,不然的話檔案系統會繼續往後長
2. 該 guest 系統用個開機光碟開機,當然我是用 iso 檔,一樣的
3. 光碟開機後進試用模式,掛載時請使用唯讀:
mount /dev/sda1 /mnt -o ro
4. /mnt/usr/sbin/zerofree /dev/sda1
之後將 gesut os 關機,並回到 host 系統
5. 參考這篇, VboxManage modifyvdi /path/to/your/VM.vdi compact
1. guest 系統裡面請安裝 zerofree, 它不大,作用就是把已經刪除的 inode 資料清空,不然的話檔案系統會繼續往後長
2. 該 guest 系統用個開機光碟開機,當然我是用 iso 檔,一樣的
3. 光碟開機後進試用模式,掛載時請使用唯讀:
mount /dev/sda1 /mnt -o ro
4. /mnt/usr/sbin/zerofree /dev/sda1
之後將 gesut os 關機,並回到 host 系統
5. 參考這篇, VboxManage modifyvdi /path/to/your/VM.vdi compact
6. VboxManage clonehd
/path/to/your/VM.vdi name-of-clone-vm.vdi
到此已經把 vdi 縮小。
順便講一下,要複製 vdi 請勿直接用 copy, 因為那樣的話虛擬磁碟的 UUID 會是相同的,請用上面的命令來複製產生新的虛擬磁碟
2012/06/21
daily update backup file 每日更新備份檔
有次幫朋友解決她的系統,因為她對 Linux 是門外漢,負責人又離職了,而系統首先是董事長的信無法收發,發現的是積存太大,爆了。後來又發現所有人都無法登入,一查,發現的是整顆硬碟爆了。
結論如下:
1. 該系統是磁碟陣列,但是只裝一顆硬碟。
2. 那顆硬碟只有 300G, 給 var, home 各約一半,大略上說啦,信箱當然在 /var/spool/mail 下,卻備份在 /home 下
3. 每週備份一次整個 /var 及 /home
有發現問題嗎?問題來了,還不止一個,有誰看出來了嗎?整個!還是整個 /home!!!!
暫時解決方案就是把舊的備份檔砍了,只留一個最新的,而 /home 則是整個砍了。/var 還沒什麼大問題,比較嚴重的也只有她家董事長的信箱一個人就占了 1GB, 不大啦,但是每週備份也就不小喔。
而 /home 則成等比級數成長,所以該負責員工一離職,一週左右就出問題了。現在提供一下要更新備份檔的作法參考如下:
先初始一個第0階的備份檔:
$ tar --create --listed-incremental ./game.snar --gzip \
--file game_`date +%F`.tar.gz game/ 2>&1 >> game_`date +%F`.log
接下來,備份時可以只針對比第0階的備份檔新的才更新,其中時間的參考檔是 game.snar,所以這個檔請不要亂刪。之後產生的都稱之為 level 1 的備份檔。
$ tar --create --listed-incremental ./game.snar --gzip \ --file game_`date +%F`.tar.gz game/>>game_`date +%F`.log
要還原的話,參考命令如下:
$ for t in game_2011-10-2*.tar.gz; \
do tar --extract --incremental --gzip --file $t; done
2012/05/24
2012/05/22
RS232
有些字眼其實很容易混淆人,不久前,有同事就在問『什麼是 RS232』?『跟 Serial Port的差異』?『那什麼又是 COM Port』?
不管這個,先回想一下,在 linux 上要對 COM Port 做 I/O 其實很簡單,一般是用 minicom 這支工具,但是基本觀念若懂的話,也可以在 console mode 下命令,可以參考這篇
1. 確認你的 COM port, 像我的是 /dev/ttyUSB0
2. 確認設定,例如我的是 115200, 8N1, off
--> stty -F /dev/ttyUSB0 raw ispeed 115200 ospeed 115200 cs8 -ignpar -cstopb -ixon
不管這個,先回想一下,在 linux 上要對 COM Port 做 I/O 其實很簡單,一般是用 minicom 這支工具,但是基本觀念若懂的話,也可以在 console mode 下命令,可以參考這篇
1. 確認你的 COM port, 像我的是 /dev/ttyUSB0
2. 確認設定,例如我的是 115200, 8N1, off
--> stty -F /dev/ttyUSB0 raw ispeed 115200 ospeed 115200 cs8 -ignpar -cstopb -ixon
3. 讀取: cat /dev/ttyUSB0, 或是上面那篇參考文件裡面也有些技巧可用
4. 寫入 echo "CONTENT" > /dev/ttyUSB0
PS1: 步驟2的設定,只要在同一個 console 執行過一次,當然不同的 console(例如重開機,重登入等)都得設定過一次,也可以寫在 .bashrc 中
PS2: 步驟 3, 4 可以同時做,也就是用一個 console 做 cat, 這樣不會離開,再用另一個 console 寫入
訂閱:
文章 (Atom)