Skip to content

Instantly share code, notes, and snippets.

View habibiefaried's full-sized avatar
🏃‍♂️
Working non-stop

Habibie Faried habibiefaried

🏃‍♂️
Working non-stop
View GitHub Profile
@habibiefaried
habibiefaried / netstatcheck.sh
Last active June 20, 2023 00:02
Check outgoing port
#!/bin/bash
is_someprocess_connected() {
# Run netstat command and store the output
is_someprocess_connected_somewhere=0
output=$(stdbuf -oL netstat -nputw 2>/dev/null)
port=$1
# Process the output line by line
while IFS= read -r line; do
@habibiefaried
habibiefaried / adv.tf
Created February 2, 2023 08:28
advanced usage of terraform for each
module/resource ... {
for_each = merge({
for k, v in var.hashmap : k => { v:v, addkey: addvalue}
},
{
for k in var.list : k => {v: v1, addkey: addvalue2}
})
property1 = each.key
property2 = each.value.v
@habibiefaried
habibiefaried / pythonformat.sh
Last active January 31, 2023 04:44
format python code
black --line-length 120 .
isort --profile=black
@habibiefaried
habibiefaried / tabcompletion.sh
Created January 31, 2023 03:52
Example of tab completion
testfunc() {
echo "Only use tabs.. please"
echo "Your input $1"
}
complete -W "option1 input2 option3 secret4" testfunc
@habibiefaried
habibiefaried / gist:9dfab05cbae4be325cd954c6e701c51c
Created December 13, 2022 10:56 — forked from pwlin/gist:8a0d01e6428b7a96e2eb
Android : add cert to system store
https://code.google.com/p/android/issues/detail?id=32696#c5
If you have a certificate that is not
trusted by Android, when you add it, it goes in the personal cert store.
When you add a cert in this personal cert store, the system requires a
higher security level to unlock the device. But if you manage to add your
cert to the system store then you don't have this requirement. Obviously,
root is required to add a certificate to the system store, but it is quiet
easy.
@habibiefaried
habibiefaried / encrypt_file_pkcs5_pkcs7.go
Created June 8, 2022 15:28 — forked from huyinghuan/encrypt_file_pkcs5_pkcs7.go
golang encrypt with pkcs5 and pkcs7
package main
import (
"bytes"
"crypto/aes"
"crypto/cipher"
"crypto/rand"
"errors"
"io"
"io/ioutil"
@habibiefaried
habibiefaried / main.go
Created May 28, 2022 19:07 — forked from walm/main.go
Simple Golang DNS Server
package main
import (
"fmt"
"log"
"strconv"
"github.com/miekg/dns"
)
@habibiefaried
habibiefaried / proxy-2.go
Created May 21, 2022 05:08
simpler easy peasy proxy
package main
import (
"flag"
"fmt"
"io"
"log"
"net"
)
@habibiefaried
habibiefaried / proxy.go
Created May 21, 2022 04:41 — forked from vmihailenco/proxy.go
Simple TCP proxy in Golang
package main
import (
"bytes"
"encoding/hex"
"flag"
"fmt"
"io"
"log"
"net"
<vhost website>.<tld>:80 {
reverse_proxy /* 127.0.0.1:40001 {
header_up Host {host}
header_up X-Real-IP {remote_host}
header_up X-Forwarded-For {remote_host}
}
log {
output file /var/log/caddy/access.log
}