This is a open source SNMP trap receiver written in GO:
https://github.com/tiebingzhang/WapSNMP
It supports SNMP v2c and V3 traps.
It also includes utilities to perform SNMP Get and SNMP walk for both SNMP v2c and V3.
Since it is written in GO, it compiles on both Linux and Windows (and in theory also Mac OS, but not tested).
August 29, 2014
my .gitconfig
[user] name = Tiebing Zhang email = tzhang@advistatech.com [core] editor = vim [merge] tool = vimdiff [alias] d = difftool st = status -s ci = commit -a br = branch co = checkout df = diff dc = diff --cached last = log -1 HEAD --stat lg = log --stat who = shortlog -s -- [diff] renames = copy tool = gvimdiff [difftool "gvimdiff"] cmd = "gvim -d" "$LOCAL" "$REMOTE" [difftool] prompt = false [push] default = matching [sendpack] sideband = false
GO cross compile Windows binary on Linux
# set up cross compilation to windows_amd64
# you only need to do this once
cd $GOROOT/src
GOOS=windows GOARCH=amd64 ./make.bash --no-clean
# whenever you want to cross compile
cd $YOUR_APP
GOOS=windows GOARCH=amd64 go build
More at
https://inconshreveable.com/04-30-2014/cross-compiling-golang-programs-with-native-libraries/
August 12, 2014
netcat send file with progress indicator
The following C code compiles to a file nc-send-file, and it will send a file to a raw tcp socket (such as netcat with the command: nc -l -p 8000 > myfile ), with progress indicator for every 64K bytes sent.
On Windows, compile it using MinGW the following Makefile:
nc-send-file:nc-send-file.c gcc -Wall -O2 -o $@ $^ -s -lws2_32 clean: rm -f nc-send-file.exeC code:
#ifdef WIN32 #include "winsock2.h" #else #include "sys/socket.h" #include "netinet/in.h" #include "unistd.h" #endif #include "stdio.h" int main(int argc, char**argv) { FILE * fd; int sockfd,ret,n; struct sockaddr_in servaddr; char sendline[1024*64]; unsigned int totalbytes=0; if (argc != 4) { printf("usage: client [IP address] [PORT] [File]\n"); exit(1); } #ifdef WIN32 WSADATA wsaData; if (WSAStartup(MAKEWORD(2, 0), &wsaData) != 0){ fprintf(stderr, "WSAStartup() failed"); exit(1); } #endif sockfd=socket(AF_INET,SOCK_STREAM,0); memset(&servaddr,0,sizeof(servaddr)); servaddr.sin_family = AF_INET; servaddr.sin_addr.s_addr=inet_addr(argv[1]); servaddr.sin_port=htons(atoi(argv[2])); if (connect(sockfd, (struct sockaddr *)&servaddr, sizeof(servaddr))<0){ fprintf(stderr,"Error connecting to target.\n"); return -1; } fd=fopen(argv[3],"rb"); if (fd==NULL){ fprintf(stderr,"Opening file %s error\n",argv[3]); return -1; } while (1){ ret=fread(sendline, 1, sizeof(sendline),fd); if (ret==0){ if (feof(fd)){ printf("Finished. Total bytes sent:%u\n",totalbytes); }else{ printf("Error.\n"); } break; } n=send(sockfd,sendline,ret,0); if (n!=ret){ printf("did not send all in the buffer. expecting %d sent %d exit.\n", ret, n); return -1; } totalbytes+=ret; printf("sending %d bytes, total %d bytes\n",ret, totalbytes); } fclose(fd); #ifdef WIN32 closesocket(sockfd); WSACleanup(); /* Cleanup Winsock */ #else close(sockfd); #endif return 0; }
August 8, 2014
xrdp reconnect to the same session
cat xrdp/xrdp.ini
[globals]
bitmap_cache=yes
bitmap_compression=yes
port=3389
crypt_level=high
channel_code=1
[xrdp1]
name=sesman-Xvnc
lib=libvnc.so
username=ask
password=ask
ip=127.0.0.1
port=-1
[xrdp2]
name=Reconnect
lib=libvnc.so
username=ask
password=ask
ip=127.0.0.1
#port=-1
port=5910
[globals]
bitmap_cache=yes
bitmap_compression=yes
port=3389
crypt_level=high
channel_code=1
[xrdp1]
name=sesman-Xvnc
lib=libvnc.so
username=ask
password=ask
ip=127.0.0.1
port=-1
[xrdp2]
name=Reconnect
lib=libvnc.so
username=ask
password=ask
ip=127.0.0.1
#port=-1
port=5910
Use stunnel to access https
stunnel -c -d localhost:8000 -r foo:443 -P /tmp/stunnel.pid -f
Now you can access local 8000 using plaintext so that you can debug and sniff packets.
Now you can access local 8000 using plaintext so that you can debug and sniff packets.
Subscribe to:
Posts (Atom)