發表文章

目前顯示的是 2019的文章

以ngrok為例,在centos7上寫一個服務

首先要先編輯你要的服務 服務通常會在/etc/systemd/system/底下 vim /etc/systemd/system/ngrok.service 寫入: [Unit] Description=ngrokd Daemon after=network.target [Service] Type=forking ExecStart=/home/ngrokd-start.sh ExecStop=/home/ngrokd-stop.sh StandardOutput=tty [Install] WantedBy=multi-user.target 回到home目錄 創建ngrokd-start.sh 跟 ngrokd-stop.sh (別忘了要chmod改一下權限) ngrokd-start.sh 內容: #!/bin/sh /home/ngrok http 1880 -log=./log.txt & ngrokd-stop.sh 內容: #!/bin/sh ps aux | grep ngrok | awk '{print $2}' | xargs kill -9 記得寫完要 systemctl daemon-reload

ESP 8266 ESP-01S 常用的AT command

AT+CIPSTATUS                                                             //查循網路連接訊息 AT+CWLAP                                                                    //掃描AP AT+CWJAP_DEF="<AP name>","<AP password>"    //加入AP AT+CIFSR                                                                      //check esp8266 IP AT+CWQAP                                                                  //ap leave AT+CIPDOMAIN=<domainname>                               //待解析的域名,可支持長度小於64的域名 AT+RESTORE                                                               //restore to factory AT+CIPSTART="TCP","<domain or ip>",1880           //以TCP的方式與<domain or ip>的1880 port連接 AT+CIPMODE=1                                                          //以通透模式傳送 AT+CIPSEND                                                                //傳送 GET /test?token=admin HTTP/1.1\r\n User-Agent: ESP8266\r\n +++                                 

arduno uno GPS OLED 輸出

圖片
喵的咧 用U8g2來寫直接記憶體爆掉 完整程式碼如下 #include <SoftwareSerial.h> #include <TinyGPS++.h> //#include <Arduino.h> //#include <U8g2lib.h> #include <U8x8lib.h> //#ifdef U8X8_HAVE_HW_SPI #include <SPI.h> //#endif //#ifdef U8X8_HAVE_HW_I2C //#include <Wire.h> //#endif U8X8_SSD1306_128X64_NONAME_SW_I2C u8x8(/* clock=*/ SCL, /* data=*/ SDA, /* reset=*/ U8X8_PIN_NONE);   // OLEDs without Reset of the Display //U8G2_SSD1306_128X64_NONAME_F_SW_I2C u8g2(U8G2_R0, /* clock=*/ SCL, /* data=*/ SDA, /* reset=*/ U8X8_PIN_NONE);   // All Boards without Reset of the Display int RXPin = 2; int TXPin = 3; int GPSBaud = 9600; SoftwareSerial gpsSerial(RXPin, TXPin); TinyGPSPlus gps; // Create a TinyGPS++ object void setup(void) {   u8x8.begin();   u8x8.setPowerSave(0);   Serial.begin(9600);   gpsSerial.begin(GPSBaud); } void monShow(float La,float Lo,float Al){   //u8g2.clearBuffer();         // clear the internal memory   u8x8.clear();   u

(只是個筆記)linux ngrok輸出log到指定檔案

nohup ./ngrok http 1880 -log=./log.txt & cat log.txt |grep "url"

debian cowrie 開機自動啟動

首先 在cowrie的目錄底下建一個auto_honey.sh 然後 輸入 bash /home/cowrie/cowrie/bin/cowrie start 之後再 sudo nano /lib/systemd/system/cowrie.service 輸入 [Unit] Description=cowrie Daemon After=syslog.target network.target [Service] Type=simple ExecStart=su cowrie -c "/home/cowrie/auto_honey.sh" [Install] WantedBy=multi-user.target systemctl daemon-reload systemctl start cowrie

node-red nodemailer throws error Invalid login: 534-5.7.14

圖片
試著用node red寫出一個可以傳送email的API 時 遇到的email的驗證問題 nodemailer throws error Invalid login: 534-5.7.14 解決辦法: 請你試著使用瀏覽器 登入你要用的gmail帳號 再開啟以下連結 https://accounts.google.com/b/0/DisplayUnlockCaptcha 按下"繼續"應該就行了

debian 10 firewalld 0.6.3 Error: COMMAND_FAILED: '/usr/sbin/ip6tables-restore -w -n' failed: ip6tables-restore v1.8.2 (nf_tables): line 4: RULE_REPLACE failed (No such file or directory): rule in chain OUTPUT 解決辦法

根據以下網址 找到了解決辦法 https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=914694 vim /etc/firewalld/firewalld.conf 莫約第40行 應該有個InvividualCalls=no 把它改成InvividualCalls=yes 儲存離開 systemctl restat firewalld 就可以了

centos7 架設 snort IDS (版本2.9.13)

[我這邊用root] yum update cd ~ yum install -y gcc flex bison zlib libpcap pcre libdnet tcpdump yum install -y https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm yum install -y libnghttp2 yum install -y zlib-devel libpcap-devel pcre-devel libdnet-devel openssl-devel libnghttp2-devel luajit-devel wget https://www.snort.org/downloads/snort/daq-2.0.6.tar.gz wget https://www.snort.org/downloads/snort/snort-2.9.13.tar.gz tar xvzf daq-2.0.6.tar.gz cd daq-2.0.6 ./configure && make && sudo make install cd .. tar xvzf snort-2.9.13.tar.gz cd snort-2.9.13 ./configure --enable-sourcefire && make && sudo make install [這邊會有點久 要等一下] ldconfig ln -s /usr/local/bin/snort /usr/sbin/snort groupadd snort useradd snort -r -s /sbin/nologin -c SNORT_IDS -g snort sudo mkdir -p /etc/snort/rules sudo mkdir /var/log/snort sudo mkdir /usr/local/lib/snort_dynamicrules sudo chmod -R 5775 /etc/snort sudo chmod -R 5775 /var/log/snort sudo chm

centos 7 各種問題大混戰

[kernel panic-not syncing:VFS:Unable to mount root fs on unknown-block] 解決辦法:  進救援模式  sudo yum remove kernel  yum install kernel [kernel panic - not syncing: Fatal exception] 有發現最前面有給一段錯誤:kernel bug at include/linux/dma-attrs.h:53! 解決辦法:  這案例可以看以下這篇   https://bugs.centos.org/view.php?id=15497   到https://buildlogs.centos.org/c7-plus.x86_64/kernel-plus/20181126212202/3.10.0-957.el7.centos.plus.x86_64/   下載kernel-plus-3.10.0-957.el7.centos.plus.x86_64.rpm   進救援模式   記得先chmod 770   yum localinstall kernel-plus-3.10.0-957.el7.centos.plus.x86_64.rpm [grub開機順序] 由於我那個有問題的boot option 在第2個 解決辦法:  grub2-mkconfig -o /boot/grub2/grub.cfg  awk -F\' '$1=="menuentry " {print i++ " : " $2}' /etc/grub2.cfg  查看你要的是第幾號  vim /etc/default/grub  GRUB_DEFAULT=(這邊就填你要的幾號)  grub2-mkconfig -o /boot/grub2/grub.cfg [centos epel repo] wget https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm 然後安裝 [centos 讀不到 ntfs] 解決辦法:  yum

各種 IP位址 的class

對沒錯 這篇當備忘 [私有IP] class A:  10.0.0.0/8 class B:  172.16.0.0/16~172.31.0.0/16 class C:  192.168.0.0/24~ 192.168.255.0/24 [其他IP] (1)Class A:如果前1個位元是以"0"開頭的,也就是說第一個位址值由1~126開頭的IP是Class A。 (IP範圍1.x.x.x ~ 126.x.x.x) (2)Class B:如果前2個位元是以"10"開頭的,也就是說第一個位址值由128~191開頭的IP是Class B。 (IP範圍128.x.x.x ~ 191.x.x.x) (3)Class C:如果前3個位元是以"110"開頭的,也就是說第一個位址值由192~223開頭的IP是Class C。 (IP範圍192.x.x.x ~ 223.x.x.x) (4)Class D:如果前4個位元是以"1110"開頭的,也就是說第一個位址值由224~239開頭的IP是Class D。 (IP範圍224.x.x.x ~ 239.x.x.x) (5)Class E:如果前4個位元是以"1111"開頭的,也就是說第一個位址值由240~255開頭的IP是Class E。 (IP範圍240.x.x.x ~ 255.x.x.x)

IP 計算心法

本篇為作者本人一直忘記IP到底怎麼算 所以 整理成的快速心法 [IP 計算心法 ] 11111111.11111111.11111111.11111111    8bit      8bit     8bit       8bit    總共 32bit 何謂 網路位元 與 主機位元 ? 以 192.168.10.10/24 為例 : 11000000.1010000.00001010 . 00001010        [ 網路位元 ]          [ 主機位元 ] 網路位置 = 主機位元通通設為 0 廣播位置 = 主機位元通通設為 1 主機位置 = 除了網路位置 與 廣播位置 剩下的都是 主機 位置 前置碼 =/N /24 /32 之類的 N 代表網路位元的數目 子網路遮罩 = 其實跟前置碼一樣 的意思 255.255.255.0 = 11111111.11111111.11111111.00000000 = 24 個 1 = /24 基本範例 1:         172.30.128.0 /24 (255.255.255.0)                 首先 把 IP 攤開來 10101100.00011110.10000000.00000000 因為是 /24 往後數 24 位 , 24 位之後 就都是主機位置了 10101100.00011110.1000000 0 .00000000 網路位置 = 主機位元通通設為 0 所以 = 10101100.00011110.1000000 0 . 00000000 網路位置 = 172.30.128.0 廣播位置 = 主機位元通通設為 1 所以 = 10101100.00011110.1000000 0 . 11111111 廣播位置 =172.30.128.255         可見 這是網路位置 基本範例 2:         172.30.128.0/16 (255.255.0.0)         首先 把 IP 攤開來 10101100.00011110.1000

debain安裝node-red , mosquitto 以及node-red增加登入面板

apt-get install vim apt-get install curl curl -sL https://deb.nodesource.com/setup_12.x | bash - apt-get install -y nodejs npm install -g node-red npm install -g node-red-dashboard apt-get install mosquitto apt-get install firewalld systemctl enable firewalld firewall-cmd --permanent --zone=public --add-port=1880/tcp firewall-cmd --permanent --zone=public --add-port=1883/tcp firewall-cmd --permanent --zone=public --add-port=443/tcp firewall-cmd --reload systemctl enable mosquitto systemctl restart mosquitto npm install -g node-red-admin node-red-admin hash-pw 你會得到一串HASH vim setting.js 找到 Securing Node-RED的地方 把註解拿掉 把HASH填上去 儲存後離開

如何在debian 9 架.onion 網站(內附自訂義域名方法)

[以Apache為例tor架站] apt-get install tor apt-get install apache2 apt-get install php7.0 vim /etc/tor/torrc 以下兩行註解拿掉 HiddenServiceDir /var/lib/tor/hidden_service/ HiddenServicePort 80 127.0.0.1:80 systemctl restart tor systemctl restart apache cat /var/lib/tor/hidden_service/hostname >>這就是你目前的.onion網站 [完成範例 (因考慮到各種因素 只有我爽才會開) ] http://coreyohg44vgmzr2.onion/ -------------------------------------------------------------------------------------- [tor自訂義域名] https://github.com/katmagic/Shallot apt-get install git apt-get install gcc apt-get install make git clone https://github.com/katmagic/Shallot.git cd Shallot ./configure && make [問題列] 以下為編譯自訂義域名時可能遇到的問題 1. In file included from src/math.c:3:0: src/math.h:23:24: fatal error: openssl/bn.h: 沒有此一檔案或目錄  #include <openssl/bn.h> [解法]: apt-get install libssl-dev 2. error: dereferencing pointer to incomplete type 'RSA {aka struct rsa_st}' [解法]: apt-get install libssl1.

筆記-cowrie json log整理

grep "succeeded" /home/cowrie/cowrie/var/log/cowrie/*.json.* >temp_json.txt sed -i 's/"/\ /g' temp_json.txt cat temp_json.txt |awk '{print $31}' >atacker_ip.txt cat atacker_ip.txt |sort|uniq -c

powershell change uac status

最近遇到了一個需求 要用cmd或powershell做出一個可以快速切換UAC status的需求 我這邊google的結果 採用了 https://gallery.technet.microsoft.com/How-to-switch-UAC-level-0ac3ea11 這個咚咚 但是他仍需要手動啟動powershell後 到指定路徑 import之後才能用 那為甚麼不直接進控制台直接調整呢? 所以我寫出了一個batch跟一個ps1可以快速呼叫該腳本 不囉嗦 上code: [pra01.ps1] Set-ExecutionPolicy Bypass Set-ExecutionPolicy Unrestricted echo "[0]Never notIfy" echo " " echo "[1]NotIfy me only when apps try to make changes to my computer(do not dim my desktop)" echo " " echo "[2]NotIfy me only when apps try to make changes to my computer(default)" echo " " echo "[3]Always notIfy" echo " " echo "pleace enter level:" $qaq=Read-host Import-Module ./SwitchUACLevel.psm1 Set-UACLevel $qaq [main.bat] @echo off xcopy /y /q %~dp0SwitchUACLevel.psm1 C:\Windows\System32\ xcopy /y /q %~dp0pra01.ps1 C:\Windows\System32\ cls Powershell.exe -File pra01.ps1 pause del C:\Windows\System32\pra01.ps1 /f del C:\Windows\System32\SwitchU

安裝cowrie(中互動式honey pot)遇到的問題與解決

首先 apt-get 作者所寫的environment: apt-get install git python-virtualenv libssl-dev libffi-dev build-essential libpython3-dev python3-minimal authbind 有可能會遇到以下錯誤: libssl-dev : Depends: libssl1.1 (= 1.1.1-1ubuntu2) but 1.1.1-1ubuntu2.1 is to be installed E: Unable to correct problems, you have held broken packages. 這時需要 "aptitude" 這工具幫妳進行降版本的動作 apt-get install libssl-dev apt-get install libpython3-dev 記得第一個Accept this solution? [Y/n/q/?]  要選擇n 不然就跟平常apt get 一樣了XDD 之後都選擇y 這工具就會幫你安裝降版本 之後再 apt-get install git python-virtualenv libssl-dev libffi-dev build-essential libpython3-dev python3-minimal authbind 搞定

ubuntu安裝python-virtualenv

今天 想要在我的ubuntu裝上cowrie honey pot 遇到了apt源沒有python-virtualenv的情況 原來是我apt源沒有universe 參考了GOOGLE大神後 一句add-apt-repository universe 搞定 參考來源: https://discourse.mailinabox.email/t/package-python-virtualenv-has-no-installation-candidate/2834 https://askubuntu.com/questions/148638/how-do-i-enable-the-universe-repository

ubuntu 如何開機預設run level

這篇就只是稍微筆記一下 要怎麼設定ubuntu開機預設的run level systemctl set-default "你要的level" 舉例: systemctl set-default multi-user.target  #這是把開機預設的level調成純文字介面 systemctl set-default graphical.target   #這是把開機預設的level調成GUI介面 ------------------------------------------------------------------------------------------------- 可以用下面這個指令來看還有哪些runlevel systemctl list-units --type target ------------------------------------------------------------------------------------------------- UNIT                  LOAD   ACTIVE SUB    DESCRIPTION basic.target          loaded active active Basic System cryptsetup.target     loaded active active Local Encrypted Volumes getty.target          loaded active active Login Prompts local-fs-pre.target   loaded active active Local File Systems (Pre) local-fs.target       loaded active active Local File Systems multi-user.target     loaded active active Multi-User System network-online.target loaded active active Network is Online network-pre.target    lo

termux 虛擬鍵盤不見了怎麼辦? 沒關西 這有解

先檢查 家目錄裡 有沒有.termux的資料夾 如果沒有 沒關西 把以下這段CODE 貼進 xxx.sh mkdir $HOME/.termux/ ;echo "extra-keys = [['ESC','/','-','HOME','UP','END','PGUP'],['TAB','CTRL','ALT','LEFT','DOWN','RIGHT','PGDN']]" >> $HOME/.termux/termux.properties 然後./xxx.sh 之後 重啟termux 搭啦

在windows底下 自己寫一個命令出來

圖片
用習慣linux後 回到windows總是讓人有點不太習慣 主要是因為 linux命令列裡有很多很方便的指令 但windos沒有 QAQ 所以分享一個 假如自己寫出來一個程式覺得不錯 想再命令列裡一打開就能用的方法 第一種: 塞進 C:\Windows\System32裡 這種方式比較適合在程式比較小 或是滲透測試 塞別人電腦裡又怕忘了清Path (? 第二種 設定 path 使用者變數新增一個變數,我這邊取名custom_command 然後值的部分填入你的那個資料夾的絕對路徑 使用者變數的Path 添加%custom_command% 系統變數的Path部分填入%custom_command% 完工! 享受你自訂義的命令吧