Skip to content

Instantly share code, notes, and snippets.

View iomarmochtar's full-sized avatar
:octocat:
"Use the source luke"

Omar Mochtar iomarmochtar

:octocat:
"Use the source luke"
View GitHub Profile
@iomarmochtar
iomarmochtar / pyenvme.sh
Created September 1, 2023 13:51
Simple venv per directory based on python version
# put this into your .bashrc or .zshrc, to use it just type pyenvme on target working directory
function pyenvme(){
targetDir=~/pyenvme
test -d $targetDir || mkdir -p $targetDir
curDir=$(pwd)
pyEnvDir=$(echo $curDir | sed -e 's/\//_/g')
# only include for major and minor version
pyVersion=$(python --version | awk '{ print $2 }' | sed -E 's/\.[0-9]+$//')
pyEnvDirPath="${targetDir}/${pyEnvDir}/${pyVersion}"
echo "using ${pyEnvDirPath}"
@iomarmochtar
iomarmochtar / viddy_alias.sh
Created September 26, 2021 07:59
shell function to make viddy read an alias with it's arguments in zsh or bash
# modified version of https://github.com/sachaos/viddy/issues/2#issuecomment-907586514 for respecting passed arguments
# eg: vd kgp -n flux-system
function vd() {
args=$(echo $* | cut -d' ' -f 2-)
real_cmd=$(which $1 | cut -d' ' -f 4-)
viddy -d -n 1 --shell $SHELL "$real_cmd $args"
}
@iomarmochtar
iomarmochtar / centos.repo
Created July 18, 2021 04:08
Centos 7 Indonesia Repository, can be useful once want to use in Redhat. you may disable redhat yum subscription plugin first.
[centos]
name=CentOS-7
baseurl=https://mirror.dewabiz.com/centos/7/os/x86_64/
enabled=1
gpgcheck=1
gpgkey=https://mirror.dewabiz.com/centos/7/os/x86_64/RPM-GPG-KEY-CentOS-7
@iomarmochtar
iomarmochtar / config_to_dict.py
Last active December 31, 2019 07:09
Simple way to convert .ini file to dict
from configparser import ConfigParser
from pprint import pprint
def as_dict(ini_file):
config = ConfigParser()
config.read_file(open(ini_file, 'r'))
return { x: dict(config[x]) for x in config.sections() }
pprint( as_dict('main.ini') )
@iomarmochtar
iomarmochtar / ZimbraHelpers.php
Created November 17, 2019 15:37
A Simple of using zimbra api in yii2 webapp
<?php
// Author: Imam Omar Mochtar (iomarmochtar@gmail.com)
namespace app\models;
use Yii;
use Zimbra\Admin\AdminFactory;
use Zimbra\Admin\Request\CreateAccount;
use Zimbra\Struct\KeyValuePair;
use Zimbra\Struct\AccountSelector;
use Zimbra\Enum\AccountBy;
@iomarmochtar
iomarmochtar / pgadmin4.sh
Created November 16, 2019 17:29
Simple script to start & stop pgadmin4 container
#!/bin/bash
## Author: Imam Omar Mochtar (iomarmochtar@gmail.com)
## Func: Simple script to start and stop pgadmin4 container
USERNAME=admin@mail.com
PASSWORD=kacangitem
PORT=8787
IMAGE="dpage/pgadmin4"
CONTAINER="omr_pgadmin4"
@iomarmochtar
iomarmochtar / batchMoveSambaOU.sh
Created November 8, 2019 01:00
Move user's OU by sAMAccountName for samba4
#!/bin/bash
# Author: Imam Omar Mochtar (iomarmochtar@gmail.com)
# Move user's OU by sAMAccountName for samba4
# arg1 = param name, arg2 = value, arg3 = default value
getParam(){
if [ "$2"x == "x" ] && [ "$3"x == "x" ]; then
echo "$1 dimasukan diset"
exit 1
fi
import smtplib
import random
fromaddr = 'user@whatever.com'
toaddrs = 'auser@gmail.com'
subject = 'This can be a fraud'
message_id = '%032x@randommail'%random.getrandbits(128)
username = 'mcuser'
password = 'mcpassword'
@iomarmochtar
iomarmochtar / dark_ozpy.py
Created July 17, 2019 03:24
Utilizing ozpy for doing SSRF
__author__ = 'Imam Omar Mochtar (iomarmochtar@gmail.com)'
"""
WARNING : For learning purpose only !!!
This is example of utilizing ozpy for gaining zimbra admin rights through SSRF vulnerability
"""
import sys
import requests
@iomarmochtar
iomarmochtar / simpletag.py
Created July 4, 2019 07:18
a python library to generating xml tag
__author__ = ('Imam Omar Mochar', ('iomarmochtar@gmail.com',))
"""
Simple XML builder, i create it for generating HTML tag(s)
"""
# alternative of xml attribute that also become keyword in python side
ALTERNATE_MAP = {
'klass': 'class'
}