Skip to content

Instantly share code, notes, and snippets.

Avatar
🎯
Focusing

Michele "O-Zone" michelep

🎯
Focusing
View GitHub Profile
@michelep
michelep / rt-daily
Created Jul 12, 2021
Daily cron script for RR (RequestTracker) ticketing system
View rt-daily
#!/bin/bash
#
# This daily cron script needed for maintain clean RT database: remove old rejected and deleted tickets, remove old resolved tickets
#
DATE=`date --i`
# Delete rejected and deleted old tickets
/opt/rt4/sbin/rt-shredder --sqldump /var/rt4/backup/RT_old_${DATE}.sql --plugin 'Tickets=query,(Status="deleted" OR Status="rejected") AND LastUpdated > "730 days ago";limit,100' --force 2>&1
@michelep
michelep / header.php
Last active Apr 13, 2021
OpenGraph integration for Wordpress theme
View header.php
In header.php theme file, add this between <head> and </head> tags:
<?php
if ( is_single() && 'post' == get_post_type() ) {
if(has_post_thumbnail($post->ID)) {
$img_src = wp_get_attachment_url( get_post_thumbnail_id($post->ID) );
}
if($excerpt = get_the_excerpt()) {
$excerpt = strip_tags($excerpt);
$excerpt = str_replace("", "'", $excerpt);
@michelep
michelep / gist:5bd8f709e8aa02638c3a4ffe7731a777
Created Mar 27, 2021
GrayNoise check for outbound connection
View gist:5bd8f709e8aa02638c3a4ffe7731a777
sudo netstat -anp TCP | grep ESTAB | grep -v "127.0.0.1" | grep -E -o "[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}" | grep -v "$192\.\|10\." | sort -u | while read ip;do curl https://api.greynoise.io/v3/community/$ip; echo; done
@michelep
michelep / gist:c4c71868867123f5728e8234a72c2346
Created Mar 21, 2021
Short HowTo to install and configure of a Git Server on a Synology NAS
View gist:c4c71868867123f5728e8234a72c2346
For the normal work no SSH login or a admin account is needed!
1. Installing Git Server
Got to Package Center on Synology and install Git Server
Enable SSH Service from Control Panel -> Terminal & SNMP
Allow users to use Git from Main Menue -> Git Server
Create a new Shared Folder git and authorize the desired users with write permissions, that folder will contains all your Git’s
2. Create a empty Git project template
@michelep
michelep / alerts_json.py
Last active Mar 2, 2021
WAZUH - active-response fetch alerts.json to extract alert data
View alerts_json.py
#!/usr/bin/env python3
#
#
import os
import sys
from os.path import dirname, abspath
import re
import time
import requests
import urllib3
@michelep
michelep / gist:8fa4e6f629022d2874019c3de13b281a
Created Jan 29, 2021
Get all IP and MACs addresses from a Cisco router via SNMP and save into a MySQL table
View gist:8fa4e6f629022d2874019c3de13b281a
<?php
//
// Questa procedura preleva dai routers, via SNMP, l'elenco degli indirizzi IP e relativi MAC connessi, salvandoli su una tabella MySQL:
//
// --
// -- Struttura della tabella `ipMACs`
// --
//
// CREATE TABLE IF NOT EXISTS `ipMACs` (
@michelep
michelep / fortinet_wifi_password
Created Dec 17, 2020
FortiNET WiFI password generator and changer
View fortinet_wifi_password
#!/usr/bin/env python
#
######################################################
#
# WiFi network password manager
#
# Tested with FortiGATE v6.2.6 and v6.2.2
#
# This script change password for [WIFI BSSID] and send a mail with the new password
#
@michelep
michelep / WAZUH - Hot-Cold-Delete Policy
Created Dec 15, 2020
WAZUH - Hot-Cold-Delete Policy
View WAZUH - Hot-Cold-Delete Policy
{
"policy": {
"policy_id": "hot_cold_workflow",
"description": "A simple default policy that changes the replica count between hot and cold states.",
"last_updated_time": 1607978734307,
"schema_version": 1,
"error_notification": null,
"default_state": "hot",
"states": [
{
View gist:2597fc48f6da67bf7cdc3243647abddc
curl -s https://packages.wazuh.com/key/GPG-KEY-WAZUH | apt-key add -
echo "deb https://packages.wazuh.com/4.x/apt/ stable main" | tee -a /etc/apt/sources.list.d/wazuh.list
apt-get update
apt-get install wazuh-manager
sed -i "s/^deb/#deb/" /etc/apt/sources.list.d/wazuh.list
apt-get update
systemctl stop filebeat
systemctl stop kibana
sed -i "s/^deb/#deb/" /etc/apt/sources.list.d/opendistroforelasticsearch.list
apt-get update
@michelep
michelep / gist:893627c8c003cfc695ccbef8685eb3d0
Created Nov 16, 2020
Wazuh 4.x - Clean unassigned sharks in ElasticSearch
View gist:893627c8c003cfc695ccbef8685eb3d0
curl -XGET https://localhost:9200/_cat/shards -u admin:admin -k | grep UNASSIGNED | awk {'print $1'} | xargs -i curl -XDELETE "https://localhost:9200/{}" -u admin:admin -k