diff --git a/daemon.py b/daemon.py index 663e01939..f7e81bd81 100644 --- a/daemon.py +++ b/daemon.py @@ -95,6 +95,7 @@ from httpcodes import write2 from httpheaders import set_headers from daemon_utils import has_accept from daemon_utils import is_authorized +from poison import load_dictionary class PubServer(BaseHTTPRequestHandler): @@ -876,6 +877,9 @@ def run_daemon(accounts_data_dir: str, # timeout used when getting rss feeds httpd.rss_timeout_sec = 20 + # load dictionary used for LLM poisoning + httpd.dictionary = load_dictionary(base_dir) + # timeout used when checking for actor changes when clicking an avatar # and entering person options screen if check_actor_timeout < 2: diff --git a/daemon_get.py b/daemon_get.py index 78ed882bf..f1183c107 100644 --- a/daemon_get.py +++ b/daemon_get.py @@ -210,6 +210,7 @@ from daemon_get_blog import show_blog_page from daemon_get_links import edit_links2 from daemon_get_login import redirect_to_login_screen from daemon_get_login import show_login_screen +from poison import html_poisoned # Blogs can be longer, so don't show many per page MAX_POSTS_IN_BLOGS_FEED = 4 @@ -260,8 +261,13 @@ def daemon_http_get(self) -> None: # headers used by LLM scrapers if 'oai-host-hash' in self.headers: - print('GET HTTP LLM scraper bounced: ' + str(self.headers)) - http_402(self) + msg = html_poisoned(self.server.dictionary) + msg = msg.encode('utf-8') + msglen = len(msg) + set_headers(self, 'text/html', msglen, + '', calling_domain, False) + write2(self, msg) + print('GET HTTP LLM scraper poisoned: ' + str(self.headers)) return # replace invalid .well-known path, prior to checking for suspicious paths diff --git a/dictionary.txt b/dictionary.txt new file mode 100644 index 000000000..9496e1433 --- /dev/null +++ b/dictionary.txt @@ -0,0 +1,1000 @@ +a +ability +able +about +above +accept +according +account +across +act +action +activity +actually +add +address +administration +admit +adult +affect +after +again +against +age +agency +agent +ago +agree +agreement +ahead +air +all +allow +almost +alone +along +already +also +although +always +American +among +amount +analysis +and +animal +another +answer +any +anyone +anything +appear +apply +approach +area +argue +arm +around +arrive +art +article +artist +as +ask +assume +at +attack +attention +attorney +audience +author +authority +available +avoid +away +baby +back +bad +bag +ball +bank +bar +base +be +beat +beautiful +because +become +bed +before +begin +behavior +behind +believe +benefit +best +better +between +beyond +big +bill +billion +bit +black +blood +blue +board +body +book +born +both +box +boy +break +bring +brother +budget +build +building +business +but +buy +by +call +camera +campaign +can +cancer +candidate +capital +car +card +care +career +carry +case +catch +cause +cell +center +central +century +certain +certainly +chair +challenge +chance +change +character +charge +check +child +choice +choose +church +citizen +city +civil +claim +class +clear +clearly +close +coach +cold +collection +college +color +come +commercial +common +community +company +compare +computer +concern +condition +conference +Congress +consider +consumer +contain +continue +control +cost +could +country +couple +course +court +cover +create +crime +cultural +culture +cup +current +customer +cut +dark +data +daughter +day +dead +deal +death +debate +decade +decide +decision +deep +defense +degree +Democrat +democratic +describe +design +despite +detail +determine +develop +development +die +difference +different +difficult +dinner +direction +director +discover +discuss +discussion +disease +do +doctor +dog +door +down +draw +dream +drive +drop +drug +during +each +early +east +easy +eat +economic +economy +edge +education +effect +effort +eight +either +election +else +employee +end +energy +enjoy +enough +enter +entire +environment +environmental +especially +establish +even +evening +event +ever +every +everybody +everyone +everything +evidence +exactly +example +executive +exist +expect +experience +expert +explain +eye +face +fact +factor +fail +fall +family +far +fast +father +fear +federal +feel +feeling +few +field +fight +figure +fill +film +final +finally +financial +find +fine +finger +finish +fire +firm +first +fish +five +floor +fly +focus +follow +food +foot +for +force +foreign +forget +form +former +forward +four +free +friend +from +front +full +fund +future +game +garden +gas +general +generation +get +girl +give +glass +go +goal +good +government +great +green +ground +group +grow +growth +guess +gun +guy +hair +half +hand +hang +happen +happy +hard +have +he +head +health +hear +heart +heat +heavy +help +her +here +herself +high +him +himself +his +history +hit +hold +home +hope +hospital +hot +hotel +hour +house +how +however +huge +human +hundred +husband +I +idea +identify +if +image +imagine +impact +important +improve +in +include +including +increase +indeed +indicate +individual +industry +information +inside +instead +institution +interest +interesting +international +interview +into +investment +involve +issue +it +item +its +itself +job +join +just +keep +key +kid +kill +kind +kitchen +know +knowledge +land +language +large +last +late +later +laugh +law +lawyer +lay +lead +leader +learn +least +leave +left +leg +legal +less +let +letter +level +lie +life +light +like +likely +line +list +listen +little +live +local +long +look +lose +loss +lot +love +low +machine +magazine +main +maintain +major +majority +make +man +manage +management +manager +many +market +marriage +material +matter +may +maybe +me +mean +measure +media +medical +meet +meeting +member +memory +mention +message +method +middle +might +military +million +mind +minute +miss +mission +model +modern +moment +money +month +more +morning +most +mother +mouth +move +movement +movie +Mr +Mrs +much +music +must +my +myself +name +nation +national +natural +nature +near +nearly +necessary +need +network +never +new +news +newspaper +next +nice +night +no +none +nor +north +not +note +nothing +notice +now +n't +number +occur +of +off +offer +office +officer +official +often +oh +oil +ok +old +on +once +one +only +onto +open +operation +opportunity +option +or +order +organization +other +others +our +out +outside +over +own +owner +page +pain +painting +paper +parent +part +participant +particular +particularly +partner +party +pass +past +patient +pattern +pay +peace +people +per +perform +performance +perhaps +period +person +personal +phone +physical +pick +picture +piece +place +plan +plant +play +player +PM +point +police +policy +political +politics +poor +popular +population +position +positive +possible +power +practice +prepare +present +president +pressure +pretty +prevent +price +private +probably +problem +process +produce +product +production +professional +professor +program +project +property +protect +prove +provide +public +pull +purpose +push +put +quality +question +quickly +quite +race +radio +raise +range +rate +rather +reach +read +ready +real +reality +realize +really +reason +receive +recent +recently +recognize +record +red +reduce +reflect +region +relate +relationship +religious +remain +remember +remove +report +represent +Republican +require +research +resource +respond +response +responsibility +rest +result +return +reveal +rich +right +rise +risk +road +rock +role +room +rule +run +safe +same +save +say +scene +school +science +scientist +score +sea +season +seat +second +section +security +see +seek +seem +sell +send +senior +sense +series +serious +serve +service +set +seven +several +sex +sexual +shake +share +she +shoot +short +shot +should +shoulder +show +side +sign +significant +similar +simple +simply +since +sing +single +sister +sit +site +situation +six +size +skill +skin +small +smile +so +social +society +soldier +some +somebody +someone +something +sometimes +son +song +soon +sort +sound +source +south +southern +space +speak +special +specific +speech +spend +sport +spring +staff +stage +stand +standard +star +start +state +statement +station +stay +step +still +stock +stop +store +story +strategy +street +strong +structure +student +study +stuff +style +subject +success +successful +such +suddenly +suffer +suggest +summer +support +sure +surface +system +table +take +talk +task +tax +teach +teacher +team +technology +television +tell +ten +tend +term +test +than +thank +that +the +their +them +themselves +then +theory +there +these +they +thing +think +third +this +those +though +thought +thousand +threat +three +through +throughout +throw +thus +time +to +today +together +tonight +too +top +total +tough +toward +town +trade +traditional +training +travel +treat +treatment +tree +trial +trip +trouble +true +truth +try +turn +TV +two +type +under +understand +unit +until +up +upon +us +use +usually +value +various +very +victim +view +violence +visit +voice +vote +wait +walk +wall +want +war +watch +water +way +we +weapon +wear +week +weight +well +west +western +what +whatever +when +where +whether +which +while +white +who +whole +whom +whose +why +wide +wife +will +win +wind +window +wish +with +within +without +woman +wonder +word +work +worker +world +worry +would +write +writer +wrong +yard +yeah +year +yes +yet +you +young +your +yourself diff --git a/epicyon.py b/epicyon.py index 35117c9b4..ad0aadb29 100644 --- a/epicyon.py +++ b/epicyon.py @@ -123,6 +123,8 @@ from happening import dav_day_via_server from content import import_emoji from relationships import get_moved_accounts from blocking import get_blocks_via_server +from poison import html_poisoned +from poison import load_dictionary def str2bool(value_str) -> bool: @@ -440,6 +442,11 @@ def _command_options() -> None: dest='shared_items_federated_domains', help='Specify federation list for shared items, ' + 'separated by spaces') + parser.add_argument("--poisoned", "--poison", + dest='poisoned', + type=str2bool, nargs='?', + const=True, default=False, + help="Example poisoned output") parser.add_argument("--following", "--followingList", dest='followingList', type=str2bool, nargs='?', @@ -840,6 +847,14 @@ def _command_options() -> None: argb = parser.parse_args() + if argb.poisoned: + # LLM poisoning example + base_dir = os.getcwd() + dictionary = load_dictionary(base_dir) + poisoned_str = html_poisoned(dictionary) + print(poisoned_str) + sys.exit() + debug = False if argb.debug: debug = True diff --git a/poison.py b/poison.py new file mode 100644 index 000000000..782587bee --- /dev/null +++ b/poison.py @@ -0,0 +1,1046 @@ +__filename__ = "poison.py" +__author__ = "Bob Mottram" +__license__ = "AGPL3+" +__version__ = "1.5.0" +__maintainer__ = "Bob Mottram" +__email__ = "bob@libreserver.org" +__status__ = "Production" +__module_group__ = "Core" + + +import os +import random +from random import randint + +common_words = ( + "you", + "I", + "to", + "the", + "a", + "and", + "that", + "it", + "of", + "me", + "what", + "is", + "in", + "this", + "know", + "I'm", + "for", + "no", + "have", + "my", + "don't", + "just", + "not", + "do", + "be", + "on", + "your", + "was", + "we", + "it's", + "with", + "so", + "but", + "all", + "well", + "are" + "he" + "oh", + "about", + "right", + "you're", + "get", + "here", + "out", + "going", + "like", + "yeah", + "if", + "her", + "she", + "can", + "up", + "want", + "think", + "that's", + "now", + "go", + "him", + "at", + "how", + "got", + "there", + "one", + "did", + "why", + "see", + "come", + "good", + "they", + "really", + "as", + "would", + "look", + "when", + "time", + "will", + "okay", + "back", + "can't", + "mean", + "tell", + "I'll", + "from", + "hey", + "were", + "he's", + "could", + "didn't", + "yes", + "his", + "been", + "or", + "something", + "who", + "because", + "some", + "had", + "then", + "say", + "ok", + "take", + "an", + "way", + "us", + "little", + "make", + "need", + "gonna", + "never", + "we're", + "too", + "love", + "she's", + "I've", + "sure", + "them", + "more", + "over", + "our", + "sorry", + "where", + "what's", + "let", + "thing", + "am", + "maybe", + "down", + "man", + "has", + "uh", + "very", + "by", + "there's", + "should", + "anything", + "said", + "much", + "any", + "life", + "even", + "off", + "please", + "doing", + "thank", + "give", + "only", + "thought", + "help", + "two", + "talk", + "people", + "god", + "still", + "wait", + "into", + "find", + "nothing", + "again", + "things", + "let's", + "doesn't", + "call", + "told", + "great", + "before", + "better", + "ever", + "night", + "than", + "away", + "first", + "believe", + "other", + "feel", + "everything", + "work", + "you've", + "fine", + "home", + "after", + "last", + "these", + "day", + "keep", + "does", + "put", + "around", + "stop", + "they're", + "I'd", + "guy", + "long", + "isn't", + "always", + "listen", + "wanted", + "Mr", + "guys", + "huh", + "those", + "big", + "lot", + "happened", + "thanks", + "won't", + "trying", + "kind", + "wrong", + "through", + "talking", + "made", + "new", + "being", + "guess", + "hi", + "care", + "bad", + "mom", + "remember", + "getting", + "we'll", + "together", + "dad", + "leave", + "mother", + "place", + "understand", + "wouldn't", + "actually", + "hear", + "baby", + "nice", + "father", + "else", + "stay", + "done", + "wasn't", + "their", + "course", + "might", + "mind", + "every", + "enough", + "try", + "hell", + "came", + "someone", + "you'll", + "own", + "family", + "whole", + "another", + "house", + "jack", + "yourself", + "idea", + "ask", + "best", + "must", + "coming", + "old", + "looking", + "woman", + "hello", + "which", + "years", + "room", + "money", + "left", + "knew", + "tonight", + "real", + "son", + "hope", + "name", + "same", + "went", + "um", + "hmm", + "happy", + "pretty", + "saw", + "girl", + "sir", + "show", + "friend", + "already", + "saying", + "may", + "next", + "three", + "job", + "problem", + "minute", + "found", + "world", + "thinking", + "haven't", + "heard", + "honey", + "matter", + "myself", + "couldn't", + "exactly", + "having", + "ah", + "probably", + "happen", + "we've", + "hurt", + "boy", + "both", + "while", + "dead", + "gotta", + "alone", + "since", + "excuse", + "start", + "kill", + "hard", + "you'd", + "today", + "car", + "ready", + "until", + "without", + "whatever", + "wants", + "hold", + "wanna", + "yet", + "seen", + "deal", + "took", + "once", + "gone", + "called", + "morning", + "supposed", + "friends", + "head", + "stuff", + "most", + "used", + "worry", + "second", + "part", + "live", + "truth", + "school", + "face", + "forget", + "TRUE", + "business", + "each", + "cause", + "soon", + "knows", + "few", + "telling", + "wife", + "who's", + "use", + "chance", + "run", + "move", + "anyone", + "person", + "bye", + "somebody", + "dr", + "heart", + "such", + "miss", + "married", + "point", + "later", + "making", + "meet", + "anyway", + "many", + "phone", + "reason", + "damn", + "lost", + "looks", + "bring", + "case", + "turn", + "wish", + "tomorrow", + "kids", + "trust", + "check", + "change", + "end", + "late", + "anymore", + "five", + "least", + "town", + "aren't", + "ha", + "working", + "year", + "makes", + "taking", + "means", + "brother", + "play", + "hate", + "ago", + "says", + "beautiful", + "gave", + "fact", + "crazy", + "party", + "sit", + "open", + "afraid", + "between", + "important", + "rest", + "fun", + "kid", + "word", + "watch", + "glad", + "everyone", + "days", + "sister", + "minutes", + "everybody", + "bit", + "couple", + "whoa", + "either", + "mrs", + "feeling", + "daughter", + "wow", + "gets", + "asked", + "under", + "break", + "promise", + "door", + "set", + "close", + "hand", + "easy", + "question", + "doctor", + "tried", + "far", + "walk", + "needs", + "trouble", + "mine", + "though", + "times", + "different", + "killed", + "hospital", + "anybody", + "sam", + "alright", + "wedding", + "shut", + "able", + "die", + "perfect", + "police", + "stand", + "comes", + "hit", + "story", + "ya", + "mm", + "waiting", + "dinner", + "against", + "funny", + "husband", + "almost", + "stupid", + "pay", + "answer", + "four", + "office", + "cool", + "eyes", + "news", + "child", + "shouldn't", + "half", + "side", + "yours", + "moment", + "sleep", + "read", + "where's", + "started", + "young", + "men", + "sounds", + "sonny", + "lucky", + "pick", + "sometimes", + "bed", + "also", + "date", + "line", + "plan", + "hours", + "lose", + "fire", + "free", + "hands", + "serious", + "shit", + "behind", + "inside", + "high", + "ahead", + "week", + "wonderful", + "fight", + "past", + "cut", + "quite", + "number", + "he'll", + "sick", + "it'll", + "game", + "eat", + "nobody", + "goes", + "death", + "along", + "save", + "seems", + "finally", + "lives", + "worried", + "upset", + "met", + "book", + "brought", + "seem", + "sort", + "safe", + "living", + "children", + "weren't", + "leaving", + "front", + "shot", + "loved", + "asking", + "running", + "clear", + "figure", + "hot", + "felt", + "six", + "parents", + "drink", + "absolutely", + "how's", + "daddy", + "sweet", + "alive", + "Paul", + "sense", + "meant", + "happens", + "David", + "special", + "bet", + "blood", + "ain't", + "kidding", + "lie", + "full", + "meeting", + "dear", + "coffee", + "seeing", + "sound", + "fault", + "water", + "fuck", + "ten", + "women", + "john", + "welcome", + "buy", + "months", + "hour", + "speak", + "lady", + "jen", + "thinks", + "Christmas", + "body", + "order", + "outside", + "hang", + "possible", + "worse", + "company", + "mistake", + "ooh", + "handle", + "spend", + "totally", + "giving", + "control", + "here's", + "marriage", + "realize", + "power", + "president", + "unless", + "sex", + "girls", + "send", + "needed", + "taken", + "died", + "scared", + "picture", + "talked", + "jake", + "ass", + "hundred", + "changed", + "completely", + "explain", + "playing", + "certainly", + "sign", + "boys", + "relationship", + "loves", + "fucking", + "hair", + "lying", + "choice", + "anywhere", + "secret", + "future", + "weird", + "luck", + "she'll", + "max", + "Luis", + "turned", + "known", + "touch", + "kiss", + "crane", + "questions", + "obviously", + "wonder", + "pain", + "calling", + "somewhere", + "throw", + "straight", + "grace", + "cold", + "white", + "fast", + "words", + "food", + "none", + "drive", + "feelings", + "they'll", + "worked", + "marry", + "light", + "test", + "drop", + "cannot", + "frank", + "sent", + "city", + "dream", + "protect", + "twenty", + "class", + "lucy", + "surprise", + "its", + "sweetheart", + "forever", + "poor", + "looked", + "mad", + "except", + "gun", + "dance", + "takes", + "appreciate", + "especially", + "situation", + "besides", + "weeks", + "pull", + "himself", + "hasn't", + "act", + "worth", + "Sheridan", + "amazing", + "top", + "given", + "expect", + "ben", + "rather", + "Julian", + "involved", + "swear", + "piece", + "busy", + "law", + "decided", + "black", + "joey", + "happening", + "movie", + "we'd", + "catch", + "antonio", + "country", + "less", + "perhaps", + "step", + "fall", + "watching", + "kept", + "darling", + "dog", + "ms", + "win", + "air", + "honor", + "personal", + "moving", + "till", + "admit", + "problems", + "murder", + "strong", + "he'd", + "evil", + "definitely", + "feels", + "information", + "honest", + "eye", + "broke", + "missed", + "longer", + "dollars", + "tired", + "evening", + "human", + "starting", + "Ross", + "red", + "entire", + "trip", + "club", + "suppose", + "calm", + "imagine", + "fair", + "caught", + "blame", + "street", + "sitting", + "favor", + "apartment", + "court", + "terrible", + "clean", + "tony", + "learn", + "Alison", + "Rick", + "works", + "relax", + "york", + "million", + "charity", + "accident", + "wake", + "prove", + "Danny", + "smart", + "message", + "missing", + "forgot", + "small", + "interested", + "table", + "nbsp", + "become", + "craig", + "mouth", + "pregnant", + "middle", + "billy", + "ring", + "careful", + "shall", + "dude", + "team", + "ride", + "figured", + "wear", + "shoot", + "stick", + "ray", + "follow", + "bo", + "angry", + "instead", + "buddy", + "write", + "stopped", + "early", + "angel", + "nick", + "ran", + "war", + "standing", + "forgive", + "jail", + "wearing", + "ladies", + "kinda", + "lunch", + "eight", + "gotten", + "hoping", + "phoebe", + "thousand", + "ridge", + "music", + "luke", + "paper", + "tough", + "tape", + "state", + "count", + "college", + "boyfriend", + "proud", + "agree", + "birthday", + "bill", + "seven", + "they've", + "Timmy", + "history", + "share", + "offer", + "hurry", + "ow", + "feet", + "wondering", + "simple", + "decision", + "building", + "ones", + "finish", + "voice", + "herself", + "Chris", + "would've", + "list", + "mess", + "deserve", + "evidence", + "cute", + "dress", + "Richard", + "interesting", + "Jesus", + "hotel", + "enjoy", + "Ryan", + "Lindsay", + "quiet", + "concerned", + "road", + "eve", + "staying", + "short", + "beat", + "sweetie", + "mention", + "clothes", + "finished", + "fell", + "neither", + "fix", + "victor", + "respect", + "spent", + "prison", + "attention", + "holding", + "calls", + "near", + "surprised", + "bar", + "beth", + "pass", + "keeping", + "gift", + "hadn't", + "putting", + "dark", + "self", + "owe", + "using", + "nora", + "ice", + "helping", + "bitch", + "normal", + "aunt", + "lawyer", + "apart", + "certain", + "plans", + "girlfriend", + "floor", + "whether", + "everything's", + "present", + "earth", + "private", + "box", + "Dawson", + "cover", + "judge", + "upstairs", + "sake", + "mommy", + "possibly", + "worst" +) + + +def load_dictionary(base_dir: str) -> []: + """Loads a dictionary from file + """ + filename = base_dir + '/custom_dictionary.txt' + if not os.path.isfile(filename): + filename = base_dir + '/dictionary.txt' + if not os.path.isfile(filename): + return [] + + words = [] + try: + with open(filename, 'r', encoding='utf-8') as fp_dict: + words = fp_dict.read().split('\n') + except OSError: + print('EX: unable to load dictionary ' + filename) + return words + + +def html_poisoned(dictionary: []) -> str: + """Returns a poisoned HTML document for LLM response + Statistically similar to English language, but semantically worthless + """ + html_str = \ + '' + \ + '' + \ + '' + \ + 'Epicyon' + \ + '' + \ + '' + no_of_common_words = len(common_words) - 1 + paragraphs = randint(1, 5) + for _ in range(paragraphs): + html_str += '

' + sentences = randint(1, 5) + + for sentence_index in range(sentences): + sentence_str = '' + + no_of_words = randint(3, 20) + for word_index in range(no_of_words): + if randint(1, 10) <= 7: + # pick a common word + distribution = random.uniform(0.0, 1.0) + common_index = \ + int(distribution * distribution * no_of_common_words) + if word_index > 0: + sentence_str += common_words[common_index] + else: + sentence_str += common_words[common_index].title() + else: + if word_index > 0: + sentence_str += random.choice(dictionary) + else: + sentence_str += random.choice(dictionary).title() + + if randint(1, 10) > 1 or word_index >= no_of_words - 1: + sentence_str += ' ' + else: + sentence_str += ', ' + if sentence_index > 0: + html_str += ' ' + sentence_str.strip() + '.' + else: + html_str += sentence_str.strip() + '.' + html_str += '

' + html_str += '' + return html_str