Skip to content

Instantly share code, notes, and snippets.

@costastf
costastf / Directory
Last active April 10, 2018 20:11
Creates a list of files in a directory supporting exclusions for files and directories based on wildcards
#!/usr/bin/env python
# -*- coding: UTF-8 -*-
#
# File: Directory.py
# Copyright (c) 2012 by None
#
# GNU General Public Licence (GPL)
#
# This program is free software; you can redistribute it and/or modify it under
# the terms of the GNU General Public License as published by the Free Software
@costastf
costastf / gist:298a0b82dd831cb948158a5dafdb9998
Created September 21, 2017 09:08
Legacy code to identify a greek isp providers smtp server based on the ip allocated
#!/usr/bin/env python
# -*- coding: UTF-8 -*-
# File: ipConnection.py
# Copyright (c) 2010 by Costas Tyfoxylos
#
# GNU General Public Licence (GPL)
#
# This program is free software; you can redistribute it and/or modify it under
# the terms of the GNU General Public License as published by the Free Software
# Foundation; either version 2 of the License, or (at your option) any later
@costastf
costastf / gist:c5fc1dd0f73e566d312e7d6c5484b140
Created September 21, 2017 08:44
Legacy code to translate a thunderbird msgFilterRules.dat to gmail.xml format
#!/usr/bin/env python2.7
# -*- coding: UTF-8 -*-
# File: moz_filter_to_gmail
#
__author__ = 'Costas Tyfoxylos <costas.tyf@gmail.com>'
__docformat__ = 'plaintext'
__date__ = '2015-04-14'
import sys
import logging
@costastf
costastf / gist:dfa6a678dbb504ab29f8e7649e83721a
Created September 21, 2017 08:38
Legacy proof of consept to identify whether a process has been started from cli or gui on linux and windows XP
#!/usr/bin/env python
# -*- coding: UTF-8 -*-
# File: checkRunner.py
# Copyright (c) 2012 by Costas Tyfoxylos
#
# GNU General Public Licence (GPL)
#
# This program is free software; you can redistribute it and/or modify it under
# the terms of the GNU General Public License as published by the Free Software
# Foundation; either version 2 of the License, or (at your option) any later
@costastf
costastf / gist:5d3b0d736f1e8caef148bbae69ea05fd
Created September 21, 2017 07:48
Legacy pdf cropping script
import sys
from pyPdf import PdfFileWriter, PdfFileReader
input1 = PdfFileReader(file(sys.argv[1], "rb"))
output = PdfFileWriter()
ratio = 28.3
@costastf
costastf / gist:2f59954afcf9c35cb3da22b96c9c0a18
Created September 21, 2017 07:41
A hack to sync files on inotify events. Quite old proof of concept on inotify events daemonized
#!/usr/bin/env python
import os, time, pyinotify, sys
from pyinotify import WatchManager, ThreadedNotifier, ProcessEvent
from daemon import Daemon
from rdiff_backup.Main import Main as backup
mask = pyinotify.IN_ATTRIB | pyinotify.IN_DELETE | pyinotify.IN_CREATE | pyinotify.IN_MODIFY | pyinotify.IN_CLOSE_WRITE
class Watch(ProcessEvent):
@costastf
costastf / gist:2a45fbdad247ebc6d02034d846e366eb
Created September 21, 2017 07:37
Legacy proof of concept watching a usb device event on windows XP
import win32serviceutil
import win32service
import win32event
import servicemanager
import win32gui
import win32gui_struct
import win32con
import ctypes
import os
@costastf
costastf / gist:3a63389856c43dcfb22d89164aa7a5de
Created September 21, 2017 07:34
String to reverse double word
#!/usr/bin/env python
#-*- coding: UTF-8 -*-
# File: stringToReverseDoubleWord.py
# Copyright (c) 2011 by Costas Tyfoxylos
#
# GNU General Public Licence (GPL)
#
# This program is free software; you can redistribute it and/or modify it under
# the terms of the GNU General Public License as published by the Free Software
# Foundation; either version 2 of the License, or (at your option) any later
@costastf
costastf / gist:4639375098ef5dd9de59c06dd6c3b74f
Last active September 21, 2017 07:32
Legacy proof of concept code to extract the shell code of a binary
#!/usr/bin/env python
#-*- coding: UTF-8 -*-
# File: shellCodeExtract.py
# Copyright (c) 2011 by Costas Tyfoxylos
#
# GNU General Public Licence (GPL)
#
# This program is free software; you can redistribute it and/or modify it under
# the terms of the GNU General Public License as published by the Free Software
# Foundation; either version 2 of the License, or (at your option) any later
@costastf
costastf / gist:968bc0e162f0795889fd78a7d1862d01
Created September 21, 2017 07:23
Legacy script checking switch port status via snmp
from pysnmp.entity.rfc3413.oneliner import cmdgen
#################################################################################################
# Global Settings
deviceIPAddress = "10.12.250.1"
snmpPort = 161
snmp_username = "monitoring"
# Port Status Displayed Information
statusID = {1: "Disabled",
2: "Blocking",