2025年8月10日 星期日

Oracle cloud無法二階段驗證(MFA)解決方式

 


換手機或刪除oracle authenticator app後無法登入oracle cloud


取回/重設MFA

1.進入https://oc-cx-en.custhelp.com/app/chat/chat_launch

2.選擇“live agent"或Chat with a live agent

3.告知無法使用MFA,並告知以下帳戶資訊

 (1)tenancy name 

 (2)email:

 (3)phone:

 (4)Credit card: last 4 code, expiration date

(等待客服幫你重新設定MFA)


修改MFA(改為Google Authenticator):

1.登入oracle cloud free tier

login oracle cloud free tier

2.右上角使用者圖示->User Setting->My profile(左邊)->Security

3.找2-step verification->Mobile App->(右邊3點)remove

4.(右邊3點)Configure->Offline mode or use another authenticator

5.open google authenticator in your mobile phone->scan qrcode->Enter the passcode generated by the App.

2020年3月21日 星期六

The problem of executing sql query in phpmyadmin. The reason is a firewall executes security policies to defense sql injection.

PHPMyAdmin error message
---
Error in processing request
Error text: error (rejected)
It seems that the connection to server has been lost. Please check your network connectivity and server status.
---
因為資料庫教學,使用xampp架設了http server&mysql server,
但學校不開放mysql的port,想說用phpmyadmin做連線
但在家中卻發現,下sql指令時卻一定產生上面的訊息
花了一段時間才找到問題,就是因為學校防火牆會把http中的sql語句擋下來
為了防止SQL Injection...(這真的是無意義又惱人的資安問題)
所以只好進行sql語句的編碼.

If the firewall uses security policies to prevent SQL Injection, it will cause this problem.

Solution:
When the front-end send a sql statement to the backend, first use base64encoder  to encode the sql statement, after the backend receives this sql statement, use base64decoder to decode the sql statement.

front-end: jQuery Base64Ecnoder  --> https://gist.github.com/TaoK/1602210
back-end: php Base64Encoder


sql.js
$(document).on('submit', '#sqlqueryform.ajax', function (event) {
add:
$form.find('textarea[name="sql_query"]').val($.base64Encode($form.find('textarea[name="sql_query"]').val()));

after
// Coming from a bookmark dialog
...
} elseif (isset($_GET['sql_query']) && isset($_GET['sql_signature'])) {
    if (Core::checkSqlQuerySignature($_GET['sql_query'], $_GET['sql_signature'])) {
        $sql_query = $_GET['sql_query'];
    }
}
to add:
if(Util::is_base64($sql_query))  //some sql_query was encoded, but some wasn't.
$sql_query=base64_decode($sql_query); //encoded sql_query must be decoded.

header.php //include javascripts file
private function _addDefaultScripts(): void
    {
add:
$this->_scripts->addFile('jQuery.base64.js');

sql.php
after:
// Coming from a bookmark dialog

if (isset($_POST['bkm_fields']['bkm_sql_query'])) {
...
}
add:
$sql_query=base64_decode($sql_query);

functions.js
 $(document).on('click', 'input#sql_query_edit_save', function () {
add:
sqlQuery=$.base64Encode(sqlQuery);

Util.php
htmlspecialchars($sql_query)-->
htmlspecialchars(base64_encode($sql_query))

Results.php
htmlspecialchars($this->__get('sql_query'))
-->
htmlspecialchars(base64_encode($this->__get('sql_query')))

'sql_query'          => $this->__get('sql_query'),
-->
'sql_query'          => base64_encode($this->__get('sql_query')),

'sql_query' => $this->__get('sql_query'),
-->
'sql_query' => base64_encode($this->__get('sql_query')),

$this->__get('sql_query'),
-->
base64_encode($this->__get('sql_query')),

tbl_row_action.php

if (isset($original_sql_query)) {
                $sql_query = $original_sql_query;
            }

-->
if (isset($original_sql_query)) {
                $sql_query = base64_decode($original_sql_query);
            }

tbl_operations.php
$this_sql_query = 'TRUNCATE TABLE '
. Util::backquote($table);
add:

$this_sql_query=base64_encode($this_sql_query);

$this_sql_query = 'DROP TABLE '
. Util::backquote($table);
add:

StructureController.php
'drop_query' => $drop_query,
modified:
'drop_query' => base64_encode($drop_query),
...
not yet finish...---
Util.php:
The below code can't be modified, because it should be able to be edited in the inline editor of the front-end.

$retval .= Url::getHiddenInputs($GLOBALS['db'], $GLOBALS['table']);
            $retval .= '<input type="hidden" name="sql_query" value="'
                . htmlspecialchars($sql_query) . '">';//Yotrew:SQL行內編輯,不編碼


// Display the SQL query and link to MySQL documentation.
...
$error_msg .= '    </p>'. "\n"
             
. '<p>' . "\n"
             
. $formatted_sql . "\n"
-->
if(is_base64($formatted_sql))
$formatted_sql=base64_decode($formatted_sql);//Yotrew:顯示SQL敍述給使用者看,所以要解碼
            $error_msg .= '    </p>' . "\n"
                . '<p>' . "\n"
                . $formatted_sql. "\n"
                . '</p>' . "\n";

add is_utf8 &s_base64 function
//Ref:https://www.itread01.com/p/1415528.html
function is_utf8($str){
$len = strlen($str);
for($i = 0; $i < $len; $i++){
$c = ord($str[$i]);
if($c > 128){
if(($c > 247)){
return false;
}elseif($c > 239){
$bytes = 4;
}elseif($c > 223){
$bytes = 3;
}elseif ($c > 191){
$bytes = 2;
}else{
return false;
}
if(($i + $bytes) > $len){
return false;
}
while($bytes > 1){
$i++;
$b = ord($str[$i]);
if($b < 128 || $b > 191){
return false;
}
$bytes--;
}
}
}
return true;
}
//判斷是否base64加密
function is_base64($str){
//這裡多了個純字母和純數字的正則判斷
if(@preg_match('/^[0-9]*$/',$str) || @preg_match('/^[a-zA-Z]*$/',$str)){
return false;
}elseif(is_utf8(base64_decode($str)) && base64_decode($str) != ''){
return true;
}
return false;
}
---

2018年9月2日 星期日

GP 125 噴射引擎

因下大雨,所以很久沒騎機車,
想說發動看看,竟然發不動,
且充電後還是發不動,但起動馬達有正常運轉,
於是在網路上找了一些方法,
因為不是專家,所以只能試最簡單的方法,
就是把油箱蓋打開,
然後打開電源,就聽到吸氣的聲音,
應該有5秒鐘以上(加油孔那麼大要吸5秒鐘也是很誇張),
想說應該就是這個問題,
等吸完氣後,蓋上油箱蓋,一發就發動。
這個問題應該是油箱內壓外接近真空,
造成加油泵無法將油打到引擎室中,
我想平常騎車騎到一半用力催油門會失去動力應該也是這個原因,
看來平時要打開油箱蓋讓油箱內外壓力平衡。

2016年7月27日 星期三

Logitech 羅技 NX80 無線滑鼠 拆解

Logitech 羅技 NX80 無線滑鼠
圖一


這顆無線滑鼠採用的微動開關不是一般滑鼠常用的微動開關,是方形的微動開關(請參考下圖四)

拆解方式:
1. NX80總共有4顆螺絲:
    2顆在最上方,把鼠貼移掉就可看到
    2顆在電池附近,打開電池蓋就可看到1顆在右方,另一顆在電池下面(如圖三)


圖二



圖三
2. 卸完螺絲後就可以輕易分離上下蓋



圖四

圖五


2016年3月12日 星期六

網頁錄音程式-使Javascript-Recorderjs

Recorderjs是一個可以用來建立網頁式的錄音程式的套件
https://github.com/mattdiamond/Recorderjs
下載下來直接解壓縮即可使用,主要用到的2個檔案是:
1. examples目錄中的example_simple_exportwav.html
2. dist目錄中的recorder.js檔

*必須注意的是它要放在web server再由Google Chrome去存取才能正確執行,如果用Google Chrome開啟是無法使用的,主要是因為Google Chrome安全性問題。
圖一、 權限要求


圖二、執行畫面


圖三、 Firefox上無法使用


使用此套件:
1. Browser要使用Google Chrome(PC或Android皆可執行,iOS不行)(Android可以錄,但無法直接播)
    *在某個網站看到也是使用此plug-in,且可以在firefox執行,因為沒有去追蹤程式碼,但我想應該只要小小修改就可以用在firefox上。
2. 此套件必須放在web server上
3. 錄音時此套件會將錄音記錄在用戶端的記憶體內,當停止錄音時,可以直接播放或匯出wav
4. 只能錄wav,所以檔案會比較大

如果要錄完音後直接上傳到web server,則搭配javascript和伺服端程式語言(如php、jsp、asp等等)即可。 

 

2014年1月4日 星期六

Patch NS2 to Support UMTS

Patch NS2 to Support UMTS(3G)
1. Download EURANE module file
    go to http://eurane.ti-wmc.nl/
    ex. ns-2.30_eurane-1.12.diff.gz
    if your ns2 version is 2.35, patch file in here(ns-2.35_eurane-1.12.diff).[1]
2. Decompress EURANE module file to ns2's home directory
3. run patch
  Change directory to ns2's home directory
  $  patch -p1 < ns-2.30_eurane-1.12.diff  <enter>
4. make or install
5. Download testscripts from http://eurane.ti-wmc.nl/
    ex.test_tcp.tcl (need idealtrace and SNRBLERMatrix.gz files)
6. run ns

ps1. If it have some problem,you modified some file by yourself.
[Makefile.in]
-CCOPT  = @V_CCOPT@
+CCOPT  = -Wall @V_CCOPT@

        apps/pbc.o \
+       umts/am.o umts/classifier-sport.o umts/demuxer.o \
+       umts/demuxerRtModule.o  umts/networkInterface.o \
+       umts/nif-classifier.o  umts/tcs.o umts/um.o \
+       umts/umtslink.o umts/umtstrace.o \
+       umts/hsdpalink.o umts/um-hs.o \
+       umts/umts-timers.o umts/virtual_umtsmac.o \
+       umts/am-hs.o \
+       umts/umts-queue.o umts/dummy_drop_tail.o \
+       umts/error_model.o tools/coot.o \

        tcl/lib/ns-qsnode.tcl \
+       tcl/lib/ns-umts.tcl \
        @V_NS_TCL_LIB_STL@

[common/packet.h]
-static packet_t       PT_NTYPE = 73; // This MUST be the LAST one
+
+// UMTS - used by hdr_cmn class for tracing purpose
+static const packet_t PT_UM = 73;
+static const packet_t PT_AMDA = 74;
+static const packet_t PT_AMPA= 75;
+static const packet_t PT_AMPBPA = 76;
+static const packet_t PT_AMBA= 77;
+static const packet_t PT_AMPBBA= 78;
+// Used for tracking HARQ transmissions (MAC-hs PDUs)
+static const packet_t PT_AMDA_H1= 79;
+static const packet_t PT_AMDA_H2= 80;
+static const packet_t PT_AMDA_H3= 81;
+       // End UMTS
+// COOT packet
+static const packet_t PT_COOT= 82;
+
+// insert new packet types here
+static packet_t       PT_NTYPE = 83; // This MUST be the LAST one

 #endif //STL
+               // UMTS
+               name_[PT_UM] = "UM";
+                name_[PT_AMDA] = "AM_Data";
+                name_[PT_AMPA] = "AM_Pos_Ack";
+                name_[PT_AMPBPA] = "AM_Piggyback_Ack";
+                name_[PT_AMBA] = "AM_Bitmap_ack";
+                name_[PT_AMPBBA] = "AM_Piggyback_Back";
+               // For HARQ transmission tracking
+               name_[PT_AMDA_H1] = "HARQ_1";
+               name_[PT_AMDA_H2] = "HARQ_2";
+               name_[PT_AMDA_H3] = "HARQ_3";
+               // End UMTS


+               // coot
+               name_[PT_COOT]="coot";
+
                // Bell Labs (PackMime OL)

2014年1月3日 星期五

NS2 traffic files generated using VANETMobiSim(on Windows)

What is VanetMobiSim?
VanetMobiSim is tool of mobility modeling.
site:http://vanet.eurecom.fr/

Install VANETMobiSim & Generate a NS2 traffic files

1. Download VanetMobiSim sources and VanetMobiSim binaries
go to http://vanet.eurecom.fr/
download VanetMobiSim sources file
  (ex. VanetMobiSim 1.1 sources file and VanetMobiSim 1.1 binaries)

2. Downlaod CanuMobiSim
go to  http://canu.informatik.uni-stuttgart.de/mobisim/downloads/
download CanuMobiSim(ex. CanuMobiSim v1.3.4)

3 Download Apache Ant
go to http://ant.apache.org/bindownload.cgi
downloasd Apache Ant (ex. apache-ant-1.9.3-bin.zip )

4. Decompress apache-ant-x.zip to a folder
  ex. E:\VanetMobSim\ant

5. Set system variable
 (1) Add a variable "ant_home"




 (2) Add "%ant_home%\bin" to "PATH" variable



6. Decompress VanetMobiSim sources to a folder
    ex. E:\VanetMobSim\VanetMobiSim-1.1

7. Decompress CanuMobiSim, then copy "src" folder in CanuMobiSim_1_3_4_src to VanetMobiSim sources  folder
    ex. E:\VanetMobSim\CanuMobiSim_1_3_4_src
    copy E:\VanetMobSim\CanuMobiSim_1_3_4_src\src to E:\VanetMobSim\VanetMobiSim-1.1


8. open "Command Prompt" window(cmd.exe)
    (1) cd E:\VanetMobSim\VanetMobiSim-1.1
    (2) "ant patch" <enter>
9. copy VanetMobiSim binaries to sample folder in VanetMobiSim sources  folder
  copy VanetMobiSim-1.1.jar ex. E:\VanetMobSim\VanetMobiSim-1.1\samples

10. run java -jar VanetMobiSim-1.1.jar xmlfile.xml
  ex. java -jar VanetMobiSim-1.1.jar IDM_LC.xml

11. Generate NS2 traffic
  (1) modify configuration in "IDM_LC.xml"
    <!-- <extension class="de.uni_stuttgart.informatik.canu.mobisim.extensions.NSOutput" output="ns_trace.txt"/>-->
    remove <!-- ... --> ,as above
   

 (2) re-run java -jar VanetMobiSim-1.1.jar IDM_LC.xml
 (3) the ns_trace.txt is generated in the folder which is a NS2 NS2 traffic



2013年12月1日 星期日

NS2 installed on Cygwin 2013 + Windows


OS: Win7 64bit
Cygwin: 2.831(32bit)
ns2: ns2.29

[cygwin/X]

1. download cygwin setup file 
2. setup cygwin
 next->(checked) Install from Internet->Root Directory(Next)->Select Local Package Directory(Next)
->(checked)Direct connection->Choose A Download site(choose a best site, and Next)->

3.Select Packages
 a) gcc,gcc-g++,gnuplot,autoconf,make,patch,perl,tar,
 b) libxt-devel,libXmu-devel,zlib-devel,libintl,w32api(mingw-win32api/mingw-w32api)
 c)[X-Window] http://x.cygwin.com/docs/ug/setup-cygwin-x-installing.html
    xorg-server,xinit,X-start-menu-icons,twm(or WindowMaker)




[ns2]

2. modified configure or sources 
3. install

2013年8月11日 星期日

尋找老同學

尋找一位久未聯絡的國中同學
因為久未聯絡而失聯,沒有其他聯絡方法
想和他敍敍舊,若您認識他或能聯絡到他
請email給我,
或請您告訴他,"有一位阿奇同學找他"
或請他與我email聯絡,
謝謝你的協助
email:yotrew@gmail.com

姓名:蕭智榮
就讀過學校:屏東萬丹國中->屏東高中->屏東科大森林系
年紀:目前約33歲(2013年)
喜歡:打籃球,運動,看霹靂布袋戲
最後一次聯絡:約10年前



我在網路看到他與朋友爬山照片
http://tw.myblog.yahoo.com/antony-chen/article?mid=584&prev=659&next=-1






若本網頁有侵犯到您的著作或個資,email告知,我將會移除它

2013年7月8日 星期一

iPhone與iPad使用AirPrint 列印資料

iPhone與iPad使用AirPrint 列印資料

IOS:6.1
PC:Windows 7

0. 下載Windows_ AirPrint Installer   http://0rz.tw/Rzocb  http://ppt.cc/0OpV
1. 設定分享你的印表機
2. 安裝Windows_ AirPrint Installer
   a. 執行AirPrint_Installer.exe
      點選Install Airprint service後關掉AirPrint_Installer

   b. 依照你的作業系統版本執行
      AirPrint iOS 5 FIX - 64Bit
      或AirPrint iOS 5 FIX - 32Bit

   c.再執行AirPrint_Installer
     按start

3.使用iPhone或iPad來列印




Q&A
Q1:若使用Windows 7時,執行上述步驟,在iPhone或iPad上還不能找到印表機.
A1:使用網路芳鄰看是否能連到Windows 7的PC上,若不行在檢查
   控制台->網路和網際網路->網路和共用中心->變更進階共用設定->"以密碼保護共用"
   看是否是"關閉以密碼保的共用" ->"儲存變更"
Q2: AirPrint on windows不能同時使用2個iOS設備?
  1. iPhone連得上時,iPad就連不上
  2. iPad連得上時,iPhone就連不上
      Why?是Guest account只能一個人,還是AirPrint的問題?
---------------------------
參考資訊:
1. http://jaxov.com/2010/11/download-airprint-installer-for-windows-7-xp-vista/
2. http://iphone4.tw/forums/showthread.php?t=108688
3. How to Print to ANY Printer from iPhone, iPod, iPad via Windows(youtube)

2013年6月3日 星期一

日本上網 旅遊 b-mobile

到日本旅遊越來越方面,國人也喜歡到日本旅遊
因目前行動設備流行,幾乎人手一機且使用智慧型手機
想要旅遊時順便分享照片或打卡,就必須上網
到日本上網有幾種方式,
1. 向國內的電信業者申請漫遊上網
2. 到日本租用日本電信業者的行動上網
3. 到機場租用日本的行動上網分享器
4. 免開通的b-mobile

這次到日本使用行動上網是上網購買b-mobile 1GB行動上網卡,使用華為E583C無線分享器
再請日本朋友開通(使用手機開通)

將micro sim卡裝上轉接卡,轉成大sim卡,裝入華為E583C
再來是設定APN(如下及下圖)[基本上應該大部份的手機也是如此設定]

使用者:bmobile@fr      (不同卡有不同的設定)
密碼:bmobile
驗證:PAP或CHAP       (2者選一個,或是選"PAP或CHAP",反正一定要選)
APN:bmobile.ne.jp

設定完後,到日本直接開機即可使用



2012年11月13日 星期二

[OpenGL/C#] 在C#中使用OpenGL簡單的顯示文字

在C#開發OpenGL有使用CSGL等library方式來建立
在C++中要在OpenGL上顯示文字可以在網路上找到許多資料,
而C#雖然也有很多資料但是一直無法試成功,甚至會造成狂吃記憶體.
只是為了顯示簡單的文字,因此就使用C++的來改寫.

Step1.先將opengl32.dll複製到C#專案目錄或確定在\Windows\System32中有opengl32.dll
Step2.由opengl32.dll引入 wglUseFontBitmaps()與wglGetCurrentDC() 兩個函數
   [DllImport("opengl32.dll")]
        static extern System.Boolean wglUseFontBitmaps(System.IntPtr hdc, System.UInt32 first, System.UInt32 count, System.UInt32 listdbase);
        [DllImport("opengl32.dll")]
        static extern System.IntPtr wglGetCurrentDC();
Step3.撰寫以下函數,修改自(modified from:) http://blog.sina.com.cn/s/blog_9aa5c2d4010150sp.html
        void GLdrawString(string str)
        { //在OpenGL畫布上顯示文字
            int isFirstCall = 1;
            uint lists = 0;
            uint MAX_CHAR = 127;

            if (isFirstCall == 1)
            {
                isFirstCall = 0;
                lists = GL.glGenLists((int)MAX_CHAR);

                wglUseFontBitmaps(wglGetCurrentDC(), 0, MAX_CHAR, lists);
            }
            char[] str_char = str.ToCharArray();
            for (int n = 0; n < str.Length; n++)
                GL.glCallList(lists + (uint)str_char[n]);
        }


code: http://goo.gl/PhjXI

2011年9月30日 星期五

[電子]無線麥克風改造(小蜜蜂)


實在不太喜歡用麥克風,但為了保護,不得不用...
有線有牽絆,因此買了無線麥克風來使用...
無線麥克風有幾種: 1. VHF 2. UHF 3. 藍芽
而我買的是比較便宜的VHF,CP值高,但有一些問題

無線麥克風主要分為三部份
1. 麥克風部份
2. 傳輸訊號盒部份
3. 接收訊號盒部份

這種麥克風缺點是
1.  接收訊號盒容易撞壞,在插擴大機的接頭易撞斷,且卡在孔裡面
2. 麥克風接頭容易接觸不良
3. 電池用9V,一顆9V很貴
4. 只有兩個頻道...(但別人沒用,就不會有干擾問題)

改造這款主要解決前3個問題,
第1個真的很容易撞壞,我撞了一次,別了又把我新買的撞了一次,因此我有兩組麥克風
接收盒
一組改良第一個問題,另一組買延長線來解決
改造第一個問題,首先先準備一條壞掉的麥克風線
壞掉的麥克風線
把這條線焊接到接收盒的電路上,因此變成一條軟軟的線,就不怕被撞到
接收盒改造結果

第2個問題在舊的那一組發生了,所以就換新的來用,但不幸的是接收盒被撞壞了
那解決方是,就是將麥克風的接頭剪掉,直接焊在傳輸盒上,因為我又不常去換麥克風
首先先將傳輸盒拆開,再把插孔的地方焊掉
傳輸盒
再將麥克風的接頭剪掉焊到電路板上去(記得要將麥克風線穿過盒子,且兩條線要焊對)
傳輸盒改造結果

第三個問題因為傳輸的電路是用9V電池驅動
這樣比較夠力,但一顆新的勁量9V電池115元,我用大概可以撐到40小時
但如果更常用可能沒多久就要換,因此我就想說用充電電池
因為一顆9V充電"鋰"電池(600mAh)只要250~300元左右,再加充電器530元
但9V充電鋰電池最大電壓只有8.4V,所以用了一小時半之後就開始出現雜音,
雖然它還是有電,因此我異想天開地,就想說多串一顆1.2V的充電電池或1.5V電池
不過學過化學的人都知道不應該這樣做(但開關關掉應該比較不會有危險),
目前我還在實驗,看是不是能使它撐超過6~8小時
若能撐到6~8小時,那整個組合CP值就非常高
改造解決這個問題必須要準備一個9V的電池扣和一個4號電池盒
改造完盒子也蓋得起來,外觀完全看不出來...

ps. 9V充電鋰電池用專用充電器只要2小時就可以充滿,
     9V鎳氫充電池只有320mAh,要充20小時,且電壓比較高
     按照320mAh來說應該可以用個6小時,但感覺上就是自放電很快
     用一小時就開始出現雜音.且顯示沒電

聽說我是學資工和化學的,但怎麼最近都做電子系在做的事...Q_Q...
-------------------

串聯電池使用結果


一顆用了1.5小時的8.4V的鋰電用了2小時了,
還可以繼續用,應該可以撐到8小時


一顆用了1小時的鎳氫電池,再用了3小時,明顯聲音變小
等重新充電後再試看看可以用多久...


另一顆原本只能用10分鐘的鎳氫電池,目前又再用了1小時...
----
目前使用上沒什麼問題,
只是不知道4號1.2V的鎳氫電池影響9V的程度是如何