Skip to content

Instantly share code, notes, and snippets.

View slayerlab's full-sized avatar
🐞

Slayer slayerlab

🐞
View GitHub Profile
@slayerlab
slayerlab / histogram.c
Created October 21, 2018 10:36
ANSI C K&R: Horizontal & Vertical Histogram
#include <stdio.h>
/* *
* Exercise 1-13. Write a program to print a histogram of the lengths of words in
* its input. It is easy to draw the histogram with the bars horizontal; a vertical
* orientation is more challenging.
* ----
* ANSI C K&R - CHARACTER INPUT AND OUTPUT: PAGE 15
* The quantities IS_LOWER, IS_UPPER, IS_ALPHA, MAXLEN, OUT and IN (macros)
* are symbolic constant, not variables, so they do not appear in declarations.
@slayerlab
slayerlab / linux-definitions-vulnerability-oval.xml
Last active March 6, 2021 19:54
OVAL Language for detect CVE-2018-7187 vulnerability on Linux environment. This PoC was made to answer this question: https://security.stackexchange.com/questions/194557/how-to-discover-known-vulnerabilities-cves-in-go-executables
<?xml version="1.0" encoding="UTF-8"?>
<oval_definitions
xmlns="http://oval.mitre.org/XMLSchema/oval-definitions-5"
xmlns:oval="http://oval.mitre.org/XMLSchema/oval-common-5"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://oval.mitre.org/XMLSchema/oval-common-5 oval-common-schema.xsd http://oval.mitre.org/XMLSchema/oval-definitions-5 oval-definitions-schema.xsd">
<generator>
<oval:product_name>Security StackExchange Question - 194557</oval:product_name>
<oval:schema_version>5.10</oval:schema_version>
@slayerlab
slayerlab / stubs_xmlStream.js
Last active August 29, 2018 15:11
só pra mim não esquecer
const xmlStream = require('xml-stream')
, fs = require('fs')
var stream = fs.createReadStream(__dirname+'./filename.xml')
, xml = new xmlStream(stream)
xml.preserve('some_subnode', true)
xml.collect('subtime_from_some_subnode')
xml.on('endElement: item', function (node) {
console.log(node)
@slayerlab
slayerlab / stubs_events.js
Last active August 28, 2018 15:11
só pra mim não esquecer como funciona essa merda.
var EventEmitter = require('events').EventEmitter,
fs = require('fs'),
util = require('util')
var Event = new EventEmitter(),
readStream = fs.createReadStream(__dirname+'./filename.txt','utf8'),
writeStream = fs.createWriteStream(__dirname+'./filename_new.txt', {flags:'w'}),
tmp_txt = [],
v = {
@slayerlab
slayerlab / bidTimeConvert.js
Created June 13, 2018 23:00
[PoC, NodeJS] A workaround to convert time from NVDCVE feed to SecurityFocus.
#!/usr/bin/node
'use strict';
String.prototype.bidTimeConvert = function () {
let month = ['Jan', 'Feb', 'Mar', 'Apr', 'Mar', 'May', 'Jun', 'Jul', 'Ago', 'Set', 'Oct', 'Nov', 'Dec'];
let fromTime = new Date(this.toString().split('.')[0]).toLocaleString();
let fromMinutes = ((new Date(fromTime).getMinutes()).toString().length == 1) ? '0'+new Date(fromTime).getMinutes() : new Date(fromTime).getMinutes();
return (new Date(fromTime).getHours() < 12)
? month[new Date(fromTime).getMonth()+1] +' '+new Date(fromTime).getDate()+' '+new Date(fromTime).getFullYear()+' '+(new Date(fromTime).getHours() + 12)+':'+fromMinutes+'AM'
@slayerlab
slayerlab / macros
Last active July 31, 2018 21:14
Add this snippet at /usr/lib/rpm/macros
#=======
# this expanded %install scriptlet will create automatically if a directory not exists.
# So, you do not need to worry with rpm .spec file to create directory.
%__spec_install_pre %{___build_pre}\
[ "$RPM_BUILD_ROOT" != "/" ] && rm -rf "${RPM_BUILD_ROOT}"\
mkdir -p `dirname "$RPM_BUILD_ROOT"`\
mkdir "$RPM_BUILD_ROOT"\
%{nil}
@slayerlab
slayerlab / localvimrc.vim
Last active December 5, 2018 01:36
Making the BASH dive into 'Shell Style Guide' for better readability.
" Making the BASH dive into 'Shell Style Guide' for better readability.
" https://lug.fh-swf.de/vim/vim-bash/StyleGuideShell.en.pdf
" https://google.github.io/styleguide/shell.xml
syntax on " set syntax highlight turned on;
set tabstop=4 " set tabstop to tell vim how many columns a tab counts for. Linux kernel code expects each tab to be 8 columns wide. Visual studio expects each tab to be four columns wide. This is the only command here that will affect how existing text displays;
set expandtab " convertt tabs to spaces;
set shiftwidth=2 " indent is 2 spaces;
set softtabstop=2 " untab size of, instead single space;
set autoindent " always set autoindenting on;
" extras:
@slayerlab
slayerlab / poc_cpuid-vendor.c
Created April 20, 2018 20:51
[PoC, C] Get CPU hardware vendor.
#include <stdio.h>
static inline void
cpuid_vendor(char *vendor) __attribute__((always_inline));
void cpuid_write(char *);
int main(void)
{
char cpu_vendor[13];
cpuid_write(cpu_vendor);
@slayerlab
slayerlab / check-element.sh
Last active April 9, 2018 18:11
[PoC, bash] check element existence into array
#!/bin/bash
function check_v
{
local v k="$1"
shift
for v; do [[ "$v" == "$k" ]] &&
return 0;
done
return 1
@slayerlab
slayerlab / icmp_revshell.rules
Created March 24, 2018 22:34
SNORT rules: useful for trigger reverse shell attempt over icmp protocol.
alert icmp $EXTERNAL_NET any -> $HOME_NET any (msg:"Unexpected data was detected on ICMP packet into Data Segment"; itype:0; icode:0; icmp_id:1; dsize:>0; classtype:tunneling; reference:url,github.com/inquisb/icmpsh; sid:123456; rev:0)
event_filter gen_id 1, sig_id 123456, type limit, track by_src, count 1, seconds 60