Skip to content

Instantly share code, notes, and snippets.

View jorben's full-sized avatar
:fishsticks:

脚本小哥 jorben

:fishsticks:
View GitHub Profile
@jorben
jorben / get_local_addr.c
Last active December 3, 2015 01:38
巧妙的获取本机ip地址
#include <stdio.h>
#include <unistd.h>
#include <string.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <arpa/inet.h>
#include <fcntl.h>
char* get_local_addr(char* buf, size_t len);
@jorben
jorben / log_mmap.c
Last active June 8, 2022 12:26
mmap写文件,多进程
#include <stdio.h>
#include <unistd.h>
#include <string.h>
#include <stdlib.h>
#include <stdint.h>
#include <errno.h>
#include <sys/time.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <sys/mman.h>
@jorben
jorben / PLog.class.php
Created December 5, 2015 15:42
SAE日志类,日志存数据库方便查阅,适用于php,支持同账户下跨应用(多个应用使用同一个db表)
<?php
/*
-- SQL
DROP TABLE IF EXISTS `t_logs`;
CREATE TABLE IF NOT EXISTS `t_logs` (
`f_id` int(10) unsigned NOT NULL AUTO_INCREMENT,
`f_level` tinyint(4) NOT NULL,
`f_module` varchar(128) NOT NULL,
`f_time` int(10) unsigned NOT NULL,
`f_path` varchar(256) NOT NULL,
@jorben
jorben / go.exp
Created June 2, 2016 07:26
远程批量执行脚本
#!/usr/bin/expect -f
set type [lindex $argv 0 ]
set ip [lindex $argv 1 ]
set cmd [lindex $argv 2 ]
set timeout 10
if { $ip == "" } {
puts "Usage: go web 1.2.3.4"
puts "Usage: go app 1.2.3.4 dev"
puts "Usage: go tws 10.137.15.150,10.198.133.45 'uptime'"
@jorben
jorben / openssl_tool.txt
Last active December 27, 2024 01:38
RSA加解密,签名、验签文件
1) Generate RSA key:
$ openssl genrsa -out key.pem 1024
$ openssl rsa -in key.pem -text -noout
2) Save public key in pub.pem file:
$ openssl rsa -in key.pem -pubout -out pub.pem
$ openssl rsa -in pub.pem -pubin -text -noout
3) Encrypt some data:
@jorben
jorben / grep_port.sh
Created August 10, 2016 08:02
根据端口抓捕低频发包进程
#!/bin/bash
i=1
while(($i>0))
do
pid=''
PSPID=''
GOTED=`ss -natp|grep ESTAB|grep -E ":9003 "`
@jorben
jorben / p2webp.pl
Last active August 19, 2016 18:47
subversion明文密码转apache支持的webpasswd
#!/usr/bin/perl
# write by jorbenzhu, 2016-08-19
use warnings;
use strict;
open (FILE, "passwd") or die ("Can't open the passwd file!");
open (OUT_FILE, ">webpasswd") or die ("Can't open the webpasswd file!");
@jorben
jorben / win_dush.bat
Created October 16, 2016 08:24
windws 下统计指定目标路径下各文件夹的大小
@echo off
IF [%1]==[] GOTO USAGE
if NOT exist "%1" (ECHO "%1" path not exist & GOTO END)
:DIR_PATH
dir /ad /b %1 > 1.txt
@jorben
jorben / get_attach_pid.sh
Created January 5, 2017 01:50
有时候看到某个shm有好几个进程attach了,但是具体是哪些进程呢? 网上查了一下,http://stackoverflow.com/questions/5658568/how-to-list-processes-attached-to-a-shared-memory-segment-in-linux 方法是grep $shmid /proc/*/maps 可以找出attach的进程。
#!/bin/bash
if [ $# -lt 1 ]; then
echo "usage: " $0 " shmid ..."
exit 0
fi
tmpfile=/tmp/shm$$
for x ; do
@jorben
jorben / ssh_scp_proxy.md
Created June 2, 2017 09:42
SSH\SCP通过代理连接目标服务器

一、SSH over http

Corkscrew是专门为ssh提供http代理的软件,要使用corkscrew需要http代理支持HTTP CONNECT方法,建议使用squid或者ATS这类专业的代理软件,代理不建议设置认证

1.1 Corkscrew安装

下载:

wget http://agroman.net/corkscrew/corkscrew-2.0.tar.gz 编译安装: