新北市因為某些原因,不肯付錢給微軟,因此採購電腦時,不再使用微軟,而是採用 ezGO, 並要求學校開課教授 ezGO, 我想,這也算是我身邊發生的第一起微軟敗退案。當然,我知道很多熱心人士致力推廣自由軟體,至少,浪潮已經湧到我身邊來了。
言歸正傳,小羊小肯早就知道多重開機,早就知道 ubuntu, 也聽我念了很多次微軟怎樣怎樣不好,現在終於正式要學 ezGO 了,剛開學那陣子非常興奮,我就做了隨身碟開機給他們,結果一直到昨天,小羊才正式跟老師提,老師還真的說「你可以用隨身碟開機」,我都很懷疑他這個美術老師兼課的電腦老師到底懂不懂隨身碟開機啊!
其實,小羊小肯愛上 ezGO 是因為,上面有一個賽車遊戲,剛開學那週就看到了,隔週終於在課堂上玩,回家就很努力要玩,也因此更加遵守媽媽的約定,總之就是變更乖了。因為之前都是用媽媽的筆電,就算隨身碟開機很慢,但是他們沒感覺,原因就是跟學校比起來快多了。我在猜,學校的新電腦不應該比我家的慢,想必是學校是因為怕每次上課前要還原電腦麻煩,採用雲端安裝的方式吧,我猜。剛剛上網體驗了下,果然雲端啊!
小羊小肯在上了幾次課後,老是抱怨學校的開機很慢,平常在家,都是哥哥先拿我的筆電開機去玩, 話說這款賽車遊戲叫 supertuxkart, 我的 ubuntu 當然也可以安裝,但是他們喜歡用自己的帳號,喜歡用 ezGO, 所以才有先前的幾篇文章。總之,我的筆電現在可以讓他們用自己的隨身碟開機,也可以用我電腦裡的 ezGO iso 開機,也燒了光碟給他們光碟開機,當然也有 ezGO 硬碟版本的開機,花樣百出。昨天,小肯終於第一次用我的電腦「關機」,結果他發出驚嘆的口氣說,『哇,關機好快喔』。
話說,這款 supertuxkart 支援搖桿,我還特地去買了兩支,不知道這樣可不可以取代 WII? 想必還是差很遠吧,但是至少目前他們是真的玩的超開心的啊!
2014/03/21
2014/03/14
淺談虛擬機、多重開機、多重編譯環境
好像上一篇也是相關文章?
最近需要 windows, ubuntu, 各種版本的 ubuntu, ezGO....
之前我是做在一支 8G usb disk 中含有 ubuntu, GeeXboX, tiny linux,....
最近因為需要 windows, 所以用虛擬機,譬如用 vmware player for ubuntu, 或是 virtualbox....
後來又需要 ezGO, 這個超肥的 kubuntu
工作上又需要舊版的 ubuntu 來保證編譯 各種晶片的 Android, (TI, MTK, BCM...),這個有的輕易就整合在同一個開發環境中,有的沒辦法
所以啦,也是以虛擬機的方式存在。當然,我的筆電算是相當高檔就是了。
還有一種方法,就是切割多個硬碟分割區,只是不見得有辦法做到這一點,或是拿 usb 3.0 的外接 usb disk, 只是這樣的速度怎麼也快不起來,效能或許也不輸虛擬機,但是虛擬機的好處是可以多個工作環境同時存在。
有一個非常古老的方法,叫做 chroot / debootstrap ....這邊不多說,有興趣的可以上網查。
chroot 不會像虛擬機那樣占用虛擬機的資源,環境也可以自行切開,相當好用。而且硬碟空間也少非常非常多。這邊只提醒一下:
在 chroot 之前,我是這樣下命令:
cd $CHROOT_DIR
for i in dev proc srv sys tmp dev/pts ; do echo $i;sudo mount --bind /$i $i; done
chroot . /bin/bash
不用的時候,重開機是個方法,不然就是反過來 umount
當然,若要非 debian/ubuntu 的系統,還是得虛擬機或多重開機囉!
最近需要 windows, ubuntu, 各種版本的 ubuntu, ezGO....
之前我是做在一支 8G usb disk 中含有 ubuntu, GeeXboX, tiny linux,....
最近因為需要 windows, 所以用虛擬機,譬如用 vmware player for ubuntu, 或是 virtualbox....
後來又需要 ezGO, 這個超肥的 kubuntu
工作上又需要舊版的 ubuntu 來保證編譯 各種晶片的 Android, (TI, MTK, BCM...),這個有的輕易就整合在同一個開發環境中,有的沒辦法
所以啦,也是以虛擬機的方式存在。當然,我的筆電算是相當高檔就是了。
還有一種方法,就是切割多個硬碟分割區,只是不見得有辦法做到這一點,或是拿 usb 3.0 的外接 usb disk, 只是這樣的速度怎麼也快不起來,效能或許也不輸虛擬機,但是虛擬機的好處是可以多個工作環境同時存在。
有一個非常古老的方法,叫做 chroot / debootstrap ....這邊不多說,有興趣的可以上網查。
chroot 不會像虛擬機那樣占用虛擬機的資源,環境也可以自行切開,相當好用。而且硬碟空間也少非常非常多。這邊只提醒一下:
在 chroot 之前,我是這樣下命令:
cd $CHROOT_DIR
for i in dev proc srv sys tmp dev/pts ; do echo $i;sudo mount --bind /$i $i; done
chroot . /bin/bash
不用的時候,重開機是個方法,不然就是反過來 umount
當然,若要非 debian/ubuntu 的系統,還是得虛擬機或多重開機囉!
2014/03/04
各種虛擬機的檔案轉換
轉自 http://blog.sleeplessbeastie.eu/2012/04/29/virtualbox-convert-raw-image-to-vdi-and-otherwise/
VirtualBox - convert RAW image to VDI and otherwise
Posted on April, 29 2012 by milosz
VirtualBox command-line interface (VBoxManage) provides an easy way to convert raw disk image to the VDI/VMDK format and otherwise.
Let's assume that we have raw image of the sdb device:
$ sudo dd if=/dev/sdb of=./sdb.raw
To use it with VirtualBox we need to convert it to the VDI format:
$ VBoxManage convertdd sdb.raw sdb.vdi --format VDI
To use it with VMware we need to convert it to the VMDK format:
$ VBoxManage convertdd sdb.raw sdb.vmdk --format VMDK
Convert between VDI/VMDK formats:
$ VBoxManage clonehd sdb.vdi sdb.vmdk --format VMDK
$ VBoxManage clonehd sdb.vmdk sdb.vdi --format VDI
Convert to the RAW image:
$ VBoxManage clonehd sdb.vdi sdb.raw --format RAW
Alternative solution to get back raw image after applying modifications is to use qemu-img command from qemu package:
$ qemu-img convert -f vmdk sdb.vmdk -O raw sdb.raw
Now we can write image to the device:
$ sudo dd if=./sdb.raw of=/dev/sdb
2013/10/18
backup newer files
在編譯 browser, kernel, 或 android 時,會產生非常多的輸出,如果要把這些輸出檔備份下來,一個最簡單的方法是 tar --newer REF_DATE_OR_FILE -cf BACKUP.tar
也就是建立一個參考的日期或檔案,然後找出比它新的將之 tar 起來
另外,若想得到這個清單,當然也可以在 tar 完後再用 tar -t 來取得。不過若不想建立 tar 檔時怎麼處理?底下是一個 shell-script,
$ cat list-file-timestamp
#!/bin/bash
EXE=$0
EXE=${EXE##*/}
DIR=$1
[ "x$DIR" = "x" ] && DIR='.'
[ ! -d $DIR ] && DIR='.'
FORMAT=$2
[ -f BUILD-DATE ] && BUILD_DATE=BUILD-DATE
[ "x$BUILD_DATE" = "x" ] && [ -f checkenv.log ] && BUILD_DATE=checkenv.log
[ "x$BUILD_DATE" = "x" ] && [ -f ./out/target/product/pandora_g2_check-dep.log ] && BUILD_DATE=./out/target/product/pandora_g2_check-dep.log
[ "x$FORMAT" = "x" ] && FORMAT='+'
OUT=/tmp/${EXE}.lst
echo "EXE=$EXE, OUTPUT=$OUT, DIR=$DIR FORMAT=$FORMAT"
find $DIR -type f -newer $BUILD_DATE -printf "%T${FORMAT} %p\n" | sort -n -r > $OUT
用法也相當簡單:
$ list-file-timestamp
$ list-file-timestamp out
$ list-file-timestamp out @
第二個範例是指定目錄,預設是 $PWD,也就是 .
第三個是指定輸出的日期 format, 請 man find 來查,在 -printf format 項下,預設是+
用 tar 的缺點當然就是耗時耗磁碟
可是如果已經透過上面的 list-file-timestamp 建立檔案清單了,該怎樣將它備份呢?最簡單的想法是:
$ tar cf BACKUP.tar `cat LIST_FILE`
通常會因檔案太多,無法使用上面的命令,這時候可以考慮用 xargs
$ cat LIST_FILE | xargs tar uf BACKUP.tar
不過,老實講, tar 相當慢,還可以用下面的方法:
$ cat LIST_FILE | xargs -I % cp --parents % ../BACK_DIR
上面 xargs -I % 是用來指定傳給 xargs 的參數,因為預設這個參數會加在命令的最後
而 cp --parents 則是保留目錄結構
也就是建立一個參考的日期或檔案,然後找出比它新的將之 tar 起來
另外,若想得到這個清單,當然也可以在 tar 完後再用 tar -t 來取得。不過若不想建立 tar 檔時怎麼處理?底下是一個 shell-script,
$ cat list-file-timestamp
#!/bin/bash
EXE=$0
EXE=${EXE##*/}
DIR=$1
[ "x$DIR" = "x" ] && DIR='.'
[ ! -d $DIR ] && DIR='.'
FORMAT=$2
[ -f BUILD-DATE ] && BUILD_DATE=BUILD-DATE
[ "x$BUILD_DATE" = "x" ] && [ -f checkenv.log ] && BUILD_DATE=checkenv.log
[ "x$BUILD_DATE" = "x" ] && [ -f ./out/target/product/pandora_g2_check-dep.log ] && BUILD_DATE=./out/target/product/pandora_g2_check-dep.log
[ "x$FORMAT" = "x" ] && FORMAT='+'
OUT=/tmp/${EXE}.lst
echo "EXE=$EXE, OUTPUT=$OUT, DIR=$DIR FORMAT=$FORMAT"
find $DIR -type f -newer $BUILD_DATE -printf "%T${FORMAT} %p\n" | sort -n -r > $OUT
用法也相當簡單:
$ list-file-timestamp
$ list-file-timestamp out
$ list-file-timestamp out @
第二個範例是指定目錄,預設是 $PWD,也就是 .
第三個是指定輸出的日期 format, 請 man find 來查,在 -printf format 項下,預設是
用 tar 的缺點當然就是耗時耗磁碟
可是如果已經透過上面的 list-file-timestamp 建立檔案清單了,該怎樣將它備份呢?最簡單的想法是:
$ tar cf BACKUP.tar `cat LIST_FILE`
通常會因檔案太多,無法使用上面的命令,這時候可以考慮用 xargs
$ cat LIST_FILE | xargs tar uf BACKUP.tar
不過,老實講, tar 相當慢,還可以用下面的方法:
$ cat LIST_FILE | xargs -I % cp --parents % ../BACK_DIR
上面 xargs -I % 是用來指定傳給 xargs 的參數,因為預設這個參數會加在命令的最後
而 cp --parents 則是保留目錄結構
2013/10/17
縮小 vmware ubuntu vmdk 虛擬磁碟影像檔 shink
有二個步驟,先是開啟 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
$ 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/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
訂閱:
文章 (Atom)