diff --git a/README.md b/README.md index 9c9b8162b35f4d2f7a289075f9c4fc8b9bbdf670..81ca6b6b2b77fa3f3e4dbebab4bbf7972ce87c09 100644 --- a/README.md +++ b/README.md @@ -1,3 +1,21 @@ +# Chinese OBFS + +This is a fork of BullshitGenerator. + +This tool could encode (hide) any data into nonsense chinese text, to avoid the extreme censorship of chinese forum. + +This tool should be used to decode data from nonsense chinese text. + +## Format proposal + +The first section encodes the topic. + +The second section should use the bootstrap data.json and the topic above, to encode an url to actual data.json. + +The third section is the actual data section. + +---- + # ç‹—å±ä¸é€šæ–‡ç« 生æˆå™¨ # BullshitGenerator diff --git a/bullshit.py b/bullshit.py new file mode 100644 index 0000000000000000000000000000000000000000..346d886049c133252b9c56e7f7d012b7c08e9c71 --- /dev/null +++ b/bullshit.py @@ -0,0 +1,61 @@ +#!/usr/bin/python +# -*- coding: UTF-8 -*- + +import os, re +import random + +def loadJson(fileName): + import json + strList = fileName.split(".") + if strList[len(strList)-1].lower() == "json": + with open(fileName,mode='r',encoding="utf-8") as file: + return json.loads(file.read()) + +data = loadJson("data.json") +motto_data = data["famous"] # a 代表prefix_data,b代表postfix_data +prefix_data = data["before"] # 在motto_dataå‰é¢å¼„点nonsense_data +postfix_data = data['after'] # 在motto_dataåŽé¢å¼„点nonsense_data +nonsense_data = data['bosh'] # ä»£è¡¨æ–‡ç« ä¸»è¦nonsense_dataæ¥æº + +xx = "å¦ç”Ÿä¼šé€€ä¼š" + +repeat_factor = 2 + +def randomized_yield(iterable): + global repeat_factor + pool = list(iterable) * repeat_factor + while True: + random.shuffle(pool) + for ele in pool: + yield ele + +nonsense_generator = randomized_yield(nonsense_data) +motto_generator = randomized_yield(motto_data) + +def new_motto(): + global motto_generator + xx = next(motto_generator) + xx = xx.replace("a", random.choice(prefix_data) ) + xx = xx.replace("b", random.choice(postfix_data) ) + return xx + +def new_paragraph(): + xx = ". " + xx += "\r\n" + xx += " " + return xx + +if __name__ == "__main__": + xx = input("è¯·è¾“å…¥æ–‡ç« ä¸»é¢˜:") + for x in xx: + tmp = str() + while ( len(tmp) < 6000 ) : + randsrc = random.randint(0,100) + if randsrc < 5: + tmp += new_paragraph() + elif randsrc < 20 : + tmp += new_motto() + else: + tmp += next(nonsense_generator) + tmp = tmp.replace("x",xx) + print(tmp) diff --git a/readJSON.py b/readJSON.py deleted file mode 100644 index 895b1fce06cc192b35cc847379f88e5308dd6ca4..0000000000000000000000000000000000000000 --- a/readJSON.py +++ /dev/null @@ -1,12 +0,0 @@ -# -*- coding: utf-8 -*- -# @Author: Admin -# @Date: 2019-11-01 16:52:34 -# @Last Modified by: Admin -# @Last Modified time: 2019-11-01 18:18:14 -def 读JSON文件(fileName=""): - import json - if fileName!='': - strList = fileName.split(".") - if strList[len(strList)-1].lower() == "json": - with open(fileName,mode='r',encoding="utf-8") as file: - return json.loads(file.read()) diff --git "a/\350\207\252\345\212\250\347\213\227\345\261\201\344\270\215\351\200\232\346\226\207\347\253\240\347\224\237\346\210\220\345\231\250.py" "b/\350\207\252\345\212\250\347\213\227\345\261\201\344\270\215\351\200\232\346\226\207\347\253\240\347\224\237\346\210\220\345\231\250.py" deleted file mode 100644 index 2b63bfd949a9f360552fd426fbdd2e603328ecf8..0000000000000000000000000000000000000000 --- "a/\350\207\252\345\212\250\347\213\227\345\261\201\344\270\215\351\200\232\346\226\207\347\253\240\347\224\237\346\210\220\345\231\250.py" +++ /dev/null @@ -1,54 +0,0 @@ -#!/usr/bin/python -# -*- coding: UTF-8 -*- - -import os, re -import random,readJSON - -data = readJSON.读JSON文件("data.json") -å人å言 = data["famous"] # a 代表å‰é¢åž«è¯ï¼Œb代表åŽé¢åž«è¯ -å‰é¢åž«è¯ = data["before"] # 在å人å言å‰é¢å¼„ç‚¹åºŸè¯ -åŽé¢åž«è¯ = data['after'] # 在å人å言åŽé¢å¼„ç‚¹åºŸè¯ -åºŸè¯ = data['bosh'] # ä»£è¡¨æ–‡ç« ä¸»è¦åºŸè¯æ¥æº - -xx = "å¦ç”Ÿä¼šé€€ä¼š" - -é‡å¤åº¦ = 2 - -def 洗牌é历(列表): - global é‡å¤åº¦ - æ± = list(列表) * é‡å¤åº¦ - while True: - random.shuffle(æ± ) - for å…ƒç´ in æ± : - yield å…ƒç´ - -下一å¥åºŸè¯ = 洗牌é历(废è¯) -下一å¥å人å言 = 洗牌é历(å人å言) - -def æ¥ç‚¹å人å言(): - global 下一å¥å人å言 - xx = next(下一å¥å人å言) - xx = xx.replace( "a",random.choice(å‰é¢åž«è¯) ) - xx = xx.replace( "b",random.choice(åŽé¢åž«è¯) ) - return xx - -def å¦èµ·ä¸€æ®µ(): - xx = ". " - xx += "\r\n" - xx += " " - return xx - -if __name__ == "__main__": - xx = input("è¯·è¾“å…¥æ–‡ç« ä¸»é¢˜:") - for x in xx: - tmp = str() - while ( len(tmp) < 6000 ) : - 分支 = random.randint(0,100) - if 分支 < 5: - tmp += å¦èµ·ä¸€æ®µ() - elif 分支 < 20 : - tmp += æ¥ç‚¹å人å言() - else: - tmp += next(下一å¥åºŸè¯) - tmp = tmp.replace("x",xx) - print(tmp) \ No newline at end of file