Skip to content

Instantly share code, notes, and snippets.

@aldy120
aldy120 / get-logs.sh
Created December 31, 2024 12:04
Network troubleshooting script
#!/usr/bin/env bash
readonly COLLECT_DIR="./log-collector"
mkdir -p "${COLLECT_DIR}"/networking
# test some network connectivity
timeout 75 ping -A -c 10 amazon.com > "${COLLECT_DIR}"/networking/ping_amazon.com.txt
timeout 75 mtr -rwzn -c 10 -T -P 443 cors.lichi-chen.com > "${COLLECT_DIR}"/networking/mtr-icmp-cors-lichi-chen.txt
timeout 75 mtr -rwzn -c 10 cors.lichi-chen.com > "${COLLECT_DIR}"/networking/mtr-tcp-443-cors-lichi-chen.txt
Frame 12: 154 bytes on wire (1232 bits), 154 bytes captured (1232 bits)
Ethernet II, Src: 0a:7b:c9:12:9d:92 (0a:7b:c9:12:9d:92), Dst: 0a:76:4b:e9:95:8d (0a:76:4b:e9:95:8d)
Internet Protocol Version 4, Src: 172.31.0.2, Dst: 172.31.42.222
User Datagram Protocol, Src Port: 53, Dst Port: 46656
Domain Name System (response)
Transaction ID: 0x6b40
Flags: 0x8180 Standard query response, No error
Questions: 1
Answer RRs: 4
Authority RRs: 0
@aldy120
aldy120 / cipher.sh
Created May 9, 2022 19:09
Get all ciphers supported by server
#!/usr/bin/env bash
# OpenSSL requires the port number.
SERVER=$1
DELAY=1
ciphers=$(openssl ciphers 'ALL:eNULL' | sed -e 's/:/ /g')
echo Obtaining cipher list from $(openssl version).
for cipher in ${ciphers[@]}
@aldy120
aldy120 / lambda_function.py
Created May 9, 2022 15:10
fibo layer example.
import json
import fibo
def lambda_handler(event, context):
fibo.fib2(1000)
return {
'statusCode': 200,
'body': json.dumps('Hello from fibo 1000: ' + ' '.join([str(elem) for elem in fibo.fib2(100)]) )
}
# Fibonacci numbers module
def fib(n): # write Fibonacci series up to n
a, b = 0, 1
while a < n:
print(a, end=' ')
a, b = b, a+b
print()
def fib2(n): # return Fibonacci series up to n
[ec2-user@ip-172-31-42-222 ~]$ mtr --report-wide --tcp --aslookup --port 443 --report-cycles 50 --max-ttl 50 hinet.net
Start: 2022-03-28T21:33:44+0000
HOST: ip-172-31-42-222.eu-west-1.compute.internal Loss% Snt Last Avg Best Wrst StDev
1. AS??? ??? 100.0 50 0.0 0.0 0.0 0.0 0.0
2. AS??? ??? 100.0 50 0.0 0.0 0.0 0.0 0.0
3. AS??? ??? 100.0 50 0.0 0.0 0.0 0.0 0.0
4. AS??? ??? 100.0 50 0.0 0.0 0.0 0.0 0.0
5. AS??? ??? 100.0 50 0.0 0.0 0.0 0.0 0.0
6. AS??? 100.65.13.5 54.0% 50 0.4 1.9 0.4 12.0 3.2
AS??? 100.65.14.139
@aldy120
aldy120 / openssl-incomplete-chain.txt
Created March 25, 2022 20:39
openssl output for incomplete chain
ubuntu@ip-172-31-4-119:~$ openssl s_client -connect incomplete-chain.badssl.com:443 -servername incomplete-chain.badssl.com
CONNECTED(00000003)
depth=0 C = US, ST = California, L = Walnut Creek, O = Lucas Garron Torres, CN = *.badssl.com
verify error:num=20:unable to get local issuer certificate
verify return:1
depth=0 C = US, ST = California, L = Walnut Creek, O = Lucas Garron Torres, CN = *.badssl.com
verify error:num=21:unable to verify the first certificate
verify return:1
---
Certificate chain
@aldy120
aldy120 / remove-infinite-debugger.js
Created March 16, 2022 01:27
Remove infinite debugger
Function.prototype.__constructor_back = Function.prototype.constructor;
Function.prototype.constructor = function() {
if(arguments && typeof arguments[0]==='string'){
//alert("new function: "+ arguments[0]);
if("debugger" === arguments[0]){
//arguments[0]="console.log(\"anti debugger\");";
//arguments[0]=";";
return
}
}
@aldy120
aldy120 / dig.sh
Created March 2, 2022 23:43
dig gmail.com TXT
[ec2-user@ip-172-31-42-222 ~]$ dig gmail.com TXT
; <<>> DiG 9.11.4-P2-RedHat-9.11.4-26.P2.amzn2.5.2 <<>> gmail.com TXT
;; global options: +cmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 60496
;; flags: qr rd ra; QUERY: 1, ANSWER: 2, AUTHORITY: 0, ADDITIONAL: 1
;; OPT PSEUDOSECTION:
; EDNS: version: 0, flags:; udp: 4096
@aldy120
aldy120 / assume-role.sh
Last active February 24, 2022 22:04
assume role
aws sts assume-role --role-arn arn:aws:iam::32522793xxxx:role/admin-32522793xxxx --role-session-name xxx
{
"Credentials": {
"AccessKeyId": "ASIAUXOIYM7XXDCJxxxx",
"SecretAccessKey": "********",
"SessionToken": ""*******************",",
"Expiration": "2022-02-24T01:16:44+00:00"
},
"AssumedRoleUser": {
"AssumedRoleId": "AROAUXOIYM7XYUEUW****:asdf",