Skip to content

Instantly share code, notes, and snippets.

View sht's full-sized avatar

Tajinder Singh sht

View GitHub Profile

Keybase proof

I hereby claim:

  • I am sht on github.
  • I am tajinder (https://keybase.io/tajinder) on keybase.
  • I have a public key ASC1twp-tC5vAu2UIEsTirfBS5bHRbHU_T9ZM2IkOy2QeAo

To claim this, I am signing this object:

@sht
sht / git_PR_Approve.md
Last active January 25, 2022 13:29
How to approve Github pull request using access token?

How to approve Github pull request using access token?

CURL:

curl -s -H "Authorization: token ghp_BWuQzbiDANEvrQP9vZbqa5LHBAxxIzwi2gM7" \
 -X POST -d '{"event":"APPROVE"}' \
 "https://api.github.com/repos/tech-security/chatbot/pulls/4/reviews"
@sht
sht / delete-slack-messages.js
Created September 9, 2021 18:44
To delete bulk Slack messages in channel or direct conversation
#!/usr/bin/env node
// Channel ID is on the the browser URL.: https://mycompany.slack.com/messages/MYCHANNELID/
// Pass it as a parameter: node ./delete-slack-messages.js CHANNEL_ID
// CONFIGURATION #######################################################################################################
const token = 'mentioned here user token, not bot token';
// Legacy tokens are no more supported.
// Please create an app or use an existing Slack App
@sht
sht / IntrospectionQuery
Last active September 9, 2021 13:31
Introspection Query for graphQL
query IntrospectionQuery {
__schema {
queryType { name }
mutationType { name }
subscriptionType { name }
types {
...FullType
}
@sht
sht / slack-python-api.py
Created August 5, 2021 11:38
Slack API by Python
from slack_sdk import WebClient
from slack_sdk.errors import SlackApiError
client = WebClient(token="xoxb-xxxxxx")
client.chat_delete(channel='DTC82MYK7', ts='1628163247.164400')
@sht
sht / beautiful_json.py
Created June 24, 2021 11:55
to make dict or json beautiful in Python
import json
data = {Data}
d1 = json.dumps(data)
parsed = json.loads(d1)
print(json.dumps(parsed, indent=4, sort_keys=True))
@sht
sht / regex.md
Last active March 1, 2023 11:31
regex including new github tokens pattern for secrets scanning
"Slack Token": "(xox[p|b|o|a]-[0-9]{12}-[0-9]{12}-[0-9]{12}-[a-z0-9]{32})",
"RSA private key": "-----BEGIN RSA PRIVATE KEY-----",
"SSH (OPENSSH) private key": "-----BEGIN OPENSSH PRIVATE KEY-----",
"SSH (DSA) private key": "-----BEGIN DSA PRIVATE KEY-----",
"SSH (EC) private key": "-----BEGIN EC PRIVATE KEY-----",
"PGP private key block": "-----BEGIN PGP PRIVATE KEY BLOCK-----",
"Facebook Oauth": "[f|F][a|A][c|C][e|E][b|B][o|O][o|O][k|K].{0,30}['\"\\s][0-9a-f]{32}['\"\\s]",
"Twitter Oauth": "[t|T][w|W][i|I][t|T][t|T][e|E][r|R].{0,30}['\"\\s][0-9a-zA-Z]{35,44}['\"\\s]",
"Google Oauth": '("client_secret":"[a-zA-Z0-9-_]{24}")',
@sht
sht / systemSetup.sh
Last active April 13, 2021 17:36
Basic ubuntu setup
sudo apt-get update -y;
sudo apt-get upgrade -y;
sudo useradd taji;
sudo adduser --disabled-password --gecos "" taji;
sudo mkdir /home/taji;
sudo mkdir /home/taji/.ssh;
wget https://github.com/imtaji.keys
sudo mv imtaji.keys /home/taji/.ssh/authorized_keys;
sudo addgroup sec;
sudo chown -R taji:taji /home/taji/.ssh/;
@sht
sht / is_port_open.py
Last active April 15, 2021 21:33
to check the status of port on particular IP
# I don't trust nmap all the time. Alternatively, we can either use telnet for single IP or below mentioned script for multiple IPs
import socket
def checkIpPort(ip,port):
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
s.settimeout(2)
status = s.connect_ex((ip, port))
if status == 0:
@sht
sht / check_github_users.py
Last active February 3, 2024 08:28
to check weather a given username in the file exist on github or not
import string, random, requests, json
def generateUser(size=3, chars=string.ascii_lowercase + string.digits):
return ''.join(random.choice(chars) for _ in range(size))
for x in range(200):
user = generateUser()
try:
jsonData = json.loads(
requests.get(f"https://api.github.com/users/{user}").text