diff --git a/go.mod b/go.mod index ae8e5048..ac48abd9 100644 --- a/go.mod +++ b/go.mod @@ -19,8 +19,8 @@ require ( github.com/grpc-ecosystem/go-grpc-middleware/v2 v2.3.3 github.com/joho/godotenv v1.5.1 github.com/lum8rjack/go-ja4h v0.0.0-20250828030157-fa5266d50650 - github.com/m1/gospin v0.0.0-20200506075355-4345dd621d4a github.com/nicksnyder/go-i18n/v2 v2.6.0 + github.com/nikandfor/spintax v0.0.0-20181023094358-fc346b245bb3 github.com/playwright-community/playwright-go v0.5200.1 github.com/prometheus/client_golang v1.23.2 github.com/redis/go-redis/v9 v9.17.2 diff --git a/go.sum b/go.sum index 21fc228c..e8a4615b 100644 --- a/go.sum +++ b/go.sum @@ -255,7 +255,6 @@ github.com/hashicorp/go-version v1.7.0 h1:5tqGy27NaOTB8yJKUZELlFAS/LTKJkrmONwQKe github.com/hashicorp/go-version v1.7.0/go.mod h1:fltr4n8CU8Ke44wwGCBoEymUuxUHl09ZGVZPK5anwXA= github.com/huandu/xstrings v1.5.0 h1:2ag3IFq9ZDANvthTwTiqSSZLjDc+BedvHPAp5tJy2TI= github.com/huandu/xstrings v1.5.0/go.mod h1:y5/lhBue+AyNmUVz9RLU9xbLR0o4KIIExikq4ovT0aE= -github.com/inconshreveable/mousetrap v1.0.0/go.mod h1:PxqpIevigyE2G7u3NXJIT2ANytuPF1OarO4DADm73n8= github.com/jbenet/go-context v0.0.0-20150711004518-d14ea06fba99 h1:BQSFePA1RWJOlocH6Fxy8MmwDt+yVQYULKfN0RoTN8A= github.com/jbenet/go-context v0.0.0-20150711004518-d14ea06fba99/go.mod h1:1lJo3i6rXxKeerYnT8Nvf0QmHCRC1n8sfWVwXF2Frvo= github.com/joho/godotenv v1.5.1 h1:7eLL/+HRGLY0ldzfGMeQkb7vMd0as4CfYvUVzLqw0N0= @@ -283,8 +282,6 @@ github.com/lufia/plan9stats v0.0.0-20250317134145-8bc96cf8fc35 h1:PpXWgLPs+Fqr32 github.com/lufia/plan9stats v0.0.0-20250317134145-8bc96cf8fc35/go.mod h1:autxFIvghDt3jPTLoqZ9OZ7s9qTGNAWmYCjVFWPX/zg= github.com/lum8rjack/go-ja4h v0.0.0-20250828030157-fa5266d50650 h1:hhx/Mo6+Hk0mAQS5MW311ON1VlSzp0D1cYhY27IcmnI= github.com/lum8rjack/go-ja4h v0.0.0-20250828030157-fa5266d50650/go.mod h1:bMqyXOakqQIdx82d4vcnk5TIZLptZ2gLqju9xmPrWYA= -github.com/m1/gospin v0.0.0-20200506075355-4345dd621d4a h1:1SIAGB8spa9zVw6UL59uT5xQWjQMe7EK6rw7eYA8kdI= -github.com/m1/gospin v0.0.0-20200506075355-4345dd621d4a/go.mod h1:Mxpzp00JqlLiQAoV1bOlEKWjT5wbK9/YqHqTUvcE+4I= github.com/magiconair/properties v1.8.10 h1:s31yESBquKXCV9a/ScB3ESkOjUYYv+X0rg8SYxI99mE= github.com/magiconair/properties v1.8.10/go.mod h1:Dhd985XPs7jluiymwWYZ0G4Z61jb3vdS329zhj2hYo0= github.com/matryer/is v1.4.0 h1:sosSmIWwkYITGrxZ25ULNDeKiMNzFSr4V/eqBQP0PeE= @@ -323,6 +320,8 @@ github.com/natefinch/atomic v1.0.1 h1:ZPYKxkqQOx3KZ+RsbnP/YsgvxWQPGxjC0oBt2AhwV0 github.com/natefinch/atomic v1.0.1/go.mod h1:N/D/ELrljoqDyT3rZrsUmtsuzvHkeB/wWjHV22AZRbM= github.com/nicksnyder/go-i18n/v2 v2.6.0 h1:C/m2NNWNiTB6SK4Ao8df5EWm3JETSTIGNXBpMJTxzxQ= github.com/nicksnyder/go-i18n/v2 v2.6.0/go.mod h1:88sRqr0C6OPyJn0/KRNaEz1uWorjxIKP7rUUcvycecE= +github.com/nikandfor/spintax v0.0.0-20181023094358-fc346b245bb3 h1:foZ9X1bz2KmW7b8Yx5V0LAQKhTazdllv5rnGUe6iGTY= +github.com/nikandfor/spintax v0.0.0-20181023094358-fc346b245bb3/go.mod h1:wwDYKfVF3WHdY0rugsAZoIpyQjDA3bn9wEzo/QXPx1Y= github.com/onsi/gomega v1.35.1 h1:Cwbd75ZBPxFSuZ6T+rN/WCb/gOc6YgFBXLlZLhC7Ds4= github.com/onsi/gomega v1.35.1/go.mod h1:PvZbdDc8J6XJEpDK4HCuRBm8a6Fzp9/DmhC9C7yFlog= github.com/opencontainers/go-digest v1.0.0 h1:apOUWs51W5PlhuyGyz9FCeeBIOUDA/6nW8Oi/yOhh5U= @@ -377,8 +376,6 @@ github.com/spf13/afero v1.14.0 h1:9tH6MapGnn/j0eb0yIXiLjERO8RB6xIVZRDCX7PtqWA= github.com/spf13/afero v1.14.0/go.mod h1:acJQ8t0ohCGuMN3O+Pv0V0hgMxNYDlvdk+VTfyZmbYo= github.com/spf13/cast v1.9.2 h1:SsGfm7M8QOFtEzumm7UZrZdLLquNdzFYfIbEXntcFbE= github.com/spf13/cast v1.9.2/go.mod h1:jNfB8QC9IA6ZuY2ZjDp0KtFO2LZZlg4S/7bzP6qqeHo= -github.com/spf13/cobra v0.0.3/go.mod h1:1l0Ry5zgKvJasoi3XT1TypsSe7PqH0Sj9dhYf7v3XqQ= -github.com/spf13/pflag v1.0.3/go.mod h1:DYY7MBk1bdzusC3SYhjObp+wFpr4gzcvqqNjLnInEg4= github.com/stoewer/go-strcase v1.3.1 h1:iS0MdW+kVTxgMoE1LAZyMiYJFKlOzLooE4MxjirtkAs= github.com/stoewer/go-strcase v1.3.1/go.mod h1:fAH5hQ5pehh+j3nZfvwdk2RgEgQjAoM8wodgtPmh1xo= github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= @@ -387,7 +384,6 @@ github.com/stretchr/objx v0.5.0/go.mod h1:Yh+to48EsGEfYuaHDzXPcE3xhTkx73EhmCGUpE github.com/stretchr/objx v0.5.2 h1:xuMeJ0Sdp5ZMRXx/aWO6RZxdr3beISkG5/G/aIRr3pY= github.com/stretchr/objx v0.5.2/go.mod h1:FRsXN1f5AsAjCGJKqEizvkpNtU+EGNCLh3NxZ/8L+MA= github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs= -github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI= github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4= github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= diff --git a/internal/headers.go b/internal/headers.go index 60e5371d..045f636a 100644 --- a/internal/headers.go +++ b/internal/headers.go @@ -1,6 +1,7 @@ package internal import ( + "context" "errors" "fmt" "log/slog" @@ -13,6 +14,13 @@ import ( "github.com/sebest/xff" ) +type realIPKey struct{} + +func RealIP(r *http.Request) (netip.Addr, bool) { + result, ok := r.Context().Value(realIPKey{}).(netip.Addr) + return result, ok +} + // TODO: move into config type XFFComputePreferences struct { StripPrivate bool @@ -77,6 +85,9 @@ func RemoteXRealIP(useRemoteAddress bool, bindNetwork string, next http.Handler) panic(err) // this should never happen } r.Header.Set("X-Real-Ip", host) + if addr, err := netip.ParseAddr(host); err == nil { + r = r.WithContext(context.WithValue(r.Context(), realIPKey{}, addr)) + } next.ServeHTTP(w, r) }) } @@ -129,8 +140,6 @@ func XForwardedForUpdate(stripPrivate bool, next http.Handler) http.Handler { } else { r.Header.Set("X-Forwarded-For", xffHeaderString) } - - slog.Debug("updating X-Forwarded-For", "original", origXFFHeader, "new", xffHeaderString) }) } diff --git a/internal/honeypot/naive/affirmations.txt b/internal/honeypot/naive/affirmations.txt index 6092398a..2b568fb9 100644 --- a/internal/honeypot/naive/affirmations.txt +++ b/internal/honeypot/naive/affirmations.txt @@ -1 +1 @@ -{Yeah|Yep|Yup|Yes|Absolutely|Definitely|Sure|Sounds|That's|I'm|I am| Totally|Completely|Totally|Right|Correct|Exactly|Perfectly|Certainly|Of course|Naturally|Indeed|Totally|Awesome|Sweet|Cool|Neat|Great|Excellent|Fantastic|Wonderful|Amazing|Love it|Nice|Right on|You bet|For sure|No doubt|Without a doubt|Undoubtedly|Indeed|Certainly|Absolutely|Positively|Definitely|Surely|Truly|Really|Genuinely|Honestly|Frankly|Literally|Exactly|Precisely|Spot on|On point|Perfectly|Ideally|Optimally|Superbly|Brilliantly|Marvelously|Splendidly|Magnificently|Phenomenally|Extraordinarily|Remarkably|Exceptionally|Outstandingly|Impressively|Stunningly|Breathtakingly|Astonishingly|Surprisingly|Pleasantly|Delightfully|Charmingly|Appealingly|Attractively|Invitingly|Encouragingly|Motivatingly|Inspiringly|Upliftingly|Positive|Optimistic|Encouraging|Supportive|Approving|Favorable|Enthusiastic|Eager|Willing|Ready|Prepared|Set|Go|Let's|Alright|Okay|Sure thing|No problem|You got it|Consider it done|Will do|Roger that|Copy that|Got it|Understood|Acknowledged|Noted|Confirmed|Agreed|Approved|Accepted|Endorsed|Supported|Backed|Championed} {sounds|looks|seems|feels|is|appears|comes across|strikes me|hits me|registers|resonates|clicks|makes sense|fits|works|functions|operates|performs|delivers|succeeds|achieves|accomplishes|excels|shines|stands out|impresses|satisfies|meets expectations|exceeds expectations|delights|pleases|gratifies|fulfills|completes|finishes|concludes|wraps up|finalizes|settles|resolves|solves|fixes|addresses|handles|manages|tackles|conquers|overcomes|defeats|beats|wins|triumphs|prevails|dominates|leads|guides|directs|steers|navigates|paves the way|opens doors|creates opportunities|makes possible|enables|allows|permits|facilitates|supports|encourages|motivates|inspires|drives|pushes|propels|launches|initiates|starts|begins|commences|kicks off|gets going|moves forward|progresses|advances|develops|evolves|grows|expands|improves|enhances|upgrades|optimizes|refines|perfects|polishes|finishes|completes} {good|great|perfect|excellent|wonderful|fantastic|amazing|awesome|fine|okay|alright|nice|cool|spot on|reasonable|about right|superb|brilliant|marvelous|splendid|magnificent|phenomenal|extraordinary|remarkable|exceptional|outstanding|impressive|stunning|breathtaking|astonishing|surprising|pleasant|delightful|charming|appealing|attractive|inviting|encouraging|motivating|inspiring|uplifting|positive|optimistic|encouraging|supportive|approving|favorable|enthusiastic|eager|willing|ready|prepared|set|solid|strong|robust|powerful|effective|efficient|productive|successful|fruitful|beneficial|valuable|useful|helpful|advantageous|profitable|rewarding|satisfying|gratifying|fulfilling|complete|whole|total|entire|full|thorough|comprehensive|exhaustive|detailed|precise|accurate|correct|right|true|valid|sound|logical|reasonable|rational|practical|realistic|feasible|possible|doable|achievable|attainable|obtainable|reachable|accessible|available|present|ready|waiting|prepared|set|arranged|organized|structured|planned|scheduled|timed|perfectly placed|well positioned|strategically located|ideally situated|perfectly suited|well matched|compatible|harmonious|balanced|proportional|symmetrical|aesthetic|beautiful|gorgeous|lovely|pretty|attractive|handsome|striking|dramatic|bold|confident|assertive|decisive|clear|obvious|apparent|evident|manifest|plain|simple|easy|straightforward|uncomplicated|complex|intricate|detailed|nuanced|subtle|refined|elegant|sophisticated|advanced|progressive|innovative|creative|original|unique|special|distinctive|memorable|unforgettable|remarkable|notable|significant|important|major|key|critical|essential|vital|crucial|fundamental|basic|primary|principal|main|chief|leading|top|best|finest|ultimate|supreme|paramount|foremost|number one|first class|world class|professional|expert|master|skilled|talented|gifted|brilliant|genius|intelligent|smart|clever|wise|knowledgeable|informed|educated|learned|scholarly|academic|theoretical|practical|applied|hands on|experienced|seasoned|veteran|mature|developed|evolved|grown|advanced|progressive|forward thinking|visionary|prophetic|intuitive|perceptive|insightful|wise|sage|profound|deep|meaningful|significant|substantial|considerable|major|important|influential|powerful|strong|robust|resilient|tough|durable|lasting|permanent|enduring|timeless|classic|traditional|conventional|standard|regular|normal|typical|usual|common|ordinary|average|mediocre|fair|decent|respectable|acceptable|satisfactory|adequate|sufficient|enough|plentiful|abundant|ample|generous|plenty|rich|wealthy|prosperous|successful|thriving|flourishing|blooming|growing|expanding|developing|improving|better|superior|higher|elevated|advanced|progressive|modern|contemporary|current|up to date|latest|new|fresh|novel|innovative|creative|original|unique|different|special|extraordinary|unusual|rare|uncommon|exceptional|outstanding|remarkable|notable|memorable|unforgettable|legendary|famous|well known|recognized|acknowledged|celebrated|acclaimed|honored|awarded|decorated|distinguished|illustrious|prestigious|reputable|respected|admired|revered|worshipped|idolized|beloved|cherished|treasured|valued|prized|precious|dear|close|intimate|personal|private|individual|unique|special|one of a kind|irreplaceable|invaluable|priceless|worthwhile|valuable|useful|beneficial|helpful|advantageous|profitable|rewarding|satisfying|gratifying|fulfilling|complete|whole|total|entire|full|perfect|ideal|ultimate|best|finest|supreme|excellent|outstanding|superior|exceptional|remarkable|extraordinary|special|unique|distinctive|memorable|impressive|striking|dramatic|powerful|strong|effective|efficient|successful|productive|fruitful|beneficial|valuable|useful|helpful|worthwhile|rewarding|satisfying|gratifying|fulfilling} {to me|for me|with me|, I agree|, I like it|, let's do it|, count me in|, I'm on board|, I'm in|, I'm up for it|, I'm down for that|, I'm all for it|, I'm good with that|, I'm happy with that|, I'm cool with that|, let's go with that|, let's make it happen|, that works|, that'll work|, sounds like a plan|, that's a good idea|, that's a great choice|, I think so too|, my thoughts exactly|, you read my mind|, couldn't agree more|, absolutely right|, you nailed it|, spot on|, perfect|, excellent|, brilliant|, outstanding|, superb|, fantastic|, wonderful|, marvelous|, splendid|, magnificent|, phenomenal|, extraordinary|, remarkable|, exceptional|, impressive|, stunning|, breathtaking|, astonishing|, amazing|, awesome|, cool|, neat|, sweet|, groovy|, far out|, wicked|, sick|, dope|, lit|, fire|, slay|, yass|, let's go|, game on|, challenge accepted|, say no more|, you had me at hello|, I'm sold|, sign me up|, I'm in|, count me in|, I'm there|, won't miss it|, be there|, definitely|, absolutely|, for sure|, no doubt|, without a doubt|, undoubtedly|, certainly|, of course|, naturally|, indeed|, truly|, really|, genuinely|, honestly|, frankly|, literally|, exactly|, precisely|, yes|, yeah|, yep|, yup|, absolutely|, definitely|, sure|, sounds good|, looks good|, seems good|, feels good|, is good|, perfect|, great|, excellent|, wonderful|, fantastic|, amazing|, awesome|, superb|, brilliant|, outstanding|, remarkable|, exceptional|, extraordinary|, impressive|, stunning|, beautiful|, gorgeous|, lovely|, pretty|, attractive|, appealing|, inviting|, encouraging|, motivating|, inspiring|, uplifting|, positive|, optimistic|, supportive|, approving|, favorable|, enthusiastic|, eager|, willing|, ready|, prepared|, set|, go|, let's do this|, time to rock|, let's roll|, here we go|, off we go|, moving forward|, full steam ahead|, all systems go|, green light|, clear for takeoff|, ready when you are|, on your mark|, get set|, let's begin|, commence operation|, initiate protocol|, execute plan|, implement strategy|, deploy solution|, activate system|, engage process|, start procedure|, begin sequence|, launch project|, kick off event|, open doors|, make way|, clear path|, pave way|, create opportunity|, make possible|, enable success|, facilitate growth|, support development|, encourage progress|, inspire change|, motivate action|, drive results|, push boundaries|, break barriers|, overcome challenges|, solve problems|, fix issues|, address concerns|, handle situations|, manage difficulties|, tackle obstacles|, conquer fears|, defeat doubts|, win battles|, triumph over adversity|, prevail against odds|, rise above|, excel beyond|, achieve greatness|, reach heights|, attain goals|, accomplish dreams|, realize potential|, fulfill destiny|, complete journey|, finish race|, cross finish line|, arrive at destination|, reach summit|, climb mountain|, sail seas|, fly skies|, explore worlds|, discover truths|, find answers|, solve mysteries|, uncover secrets|, reveal wonders|, share insights|, spread joy|, create happiness|, build relationships|, strengthen bonds|, foster community|, grow together|, learn constantly|, improve daily|, evolve continuously|, adapt quickly|, change rapidly|, transform completely|, renew fully|, refresh completely|, restart anew|, begin again|, start fresh|, clean slate|, new chapter|, fresh start|, bright future|, promising tomorrow|, better days|, good times|, great moments|, wonderful experiences|, fantastic adventures|, amazing journeys|, awesome memories|, precious moments|, valuable lessons|, helpful advice|, useful tips|, practical solutions|, effective strategies|, successful methods|, proven approaches|, tested techniques|, reliable systems|, dependable support|, consistent performance|, steady progress|, continuous improvement|, ongoing development|, perpetual growth|, endless possibilities|, unlimited potential|, infinite opportunities|, boundless horizons|, vast expanses|, wide ranges|, broad spectrums|, diverse options|, multiple choices|, various paths|, different routes|, alternative ways|, other methods|, additional approaches|, extra techniques|, supplementary tools|, auxiliary resources|, backup plans|, contingency options|, emergency measures|, safety nets|, security blankets|, comfort zones|, safe spaces|, peaceful havens|, tranquil sanctuaries|, serene environments|, calm atmospheres|, relaxed vibes|, easy feelings|, comfortable sensations|, pleasant experiences|, enjoyable moments|, delightful times|, charming encounters|, appealing situations|, attractive prospects|, inviting opportunities|, encouraging signs|, motivating factors|, inspiring elements|, uplifting aspects|, positive features|, optimistic views|, encouraging outlooks|, supportive attitudes|, approving perspectives|, favorable opinions|, enthusiastic responses|, eager reactions|, willing participants|, ready volunteers|, prepared individuals|, set teams|, organized groups|, structured units|, planned initiatives|, scheduled events|, timed activities|, perfect placements|, well positioned assets|, strategically located resources|, ideally situated elements|, perfectly suited components|, well matched partners|, compatible collaborations|, harmonious relationships|, balanced arrangements|, proportional distributions|, symmetrical designs|, aesthetic presentations|, beautiful displays|, gorgeous exhibitions|, lovely shows|, pretty sights|, attractive views|, striking scenes|, dramatic performances|, bold statements|, confident expressions|, decisive actions|, clear communications|, obvious demonstrations|, apparent revelations|, evident truths|, manifest realities|, plain facts|, simple solutions|, easy implementations|, straightforward processes|, uncomplicated procedures|, complex systems|, intricate networks|, detailed analyses|, nuanced discussions|, subtle distinctions|, refined approaches|, elegant solutions|, sophisticated methods|, advanced technologies|, progressive ideas|, innovative concepts|, creative designs|, original works|, unique creations|, special projects|, distinctive features|, memorable experiences|, unforgettable moments|, legendary achievements|, famous accomplishments|, well recognized contributions|, acknowledged impacts|, celebrated successes|, acclaimed performances|, honored achievements|, awarded excellence|, decorated heroes|, distinguished leaders|, illustrious careers|, prestigious positions|, reputable organizations|, respected institutions|, admired figures|, revered icons|, worshipped idols|, beloved personalities|, cherished treasures|, valued possessions|, prized collections|, precious artifacts|, dear friends|, close companions|, intimate partners|, personal connections|, individual expressions|, unique perspectives|, special talents|, one of a kind gifts|, irreplaceable values|, invaluable insights|, priceless wisdom|, worthwhile endeavors|, valuable investments|, useful tools|, beneficial resources|, helpful services|, advantageous positions|, profitable ventures|, rewarding careers|, satisfying lives|, gratifying experiences|, fulfilling purposes|, complete beings|, whole persons|, total entities|, entire systems|, full cycles|, perfect circles|, ideal forms|, ultimate goals|, best practices|, finest qualities|, supreme achievements|, excellent results|, outstanding performances|, superior outcomes|, exceptional contributions|, remarkable discoveries|, extraordinary breakthroughs|, special recognitions|, unique innovations|, distinctive designs|, memorable impacts|, impressive feats|, dramatic transformations|, powerful changes|, strong foundations|, effective actions|, efficient operations|, successful missions|, productive endeavors|, fruitful partnerships|, beneficial collaborations|, valuable connections|, helpful networks|, worthwhile projects|, rewarding adventures|, satisfying journeys|, gratifying accomplishments|, fulfilling destinies|too|as well|also|in addition|additionally|furthermore|moreover|plus|and|as well as|along with|together with|including|containing|comprising|embracing|encompassing|covering|spanning|ranging across|extending over|stretching through|reaching into|penetrating|entering|accessing|approaching|engaging with|participating in|joining|becoming part of|integrating with|merging with|combining with|uniting with|connecting to|linking with|attaching to|binding to|fastening to|securing to|anchoring to|grounding in|rooting in|planting in|growing in|developing in|evolving in|maturing in|flourishing in|thriving in|succeeding in|excelling in|achieving in|accomplishing in|completing in|finishing in|perfecting in|mastering in|winning in|triumphing in|prevailing in|leading in|guiding in|directing in|steering in|navigating in|exploring in|discovering in|finding in|locating in|identifying in|recognizing in|acknowledging in|accepting in|approving in|endorsing in|supporting in|backing in|championing in|promoting in|advocating in|recommending in|suggesting in|proposing in|offering in|presenting in|providing in|supplying in|delivering in|distributing in|sharing in|spreading in|broadcasting in|communicating in|expressing in|conveying in|transmitting in|sending in|receiving in|getting in|obtaining in|acquiring in|gaining in|earning in|deserving in|meriting in|qualifying for|entitled to|worthy of|deserving of|meriting of|qualifying for|eligible for|suitable for|fit for|perfect for|ideal for|right for|appropriate for|proper for|correct for|accurate for|true for|real for|genuine for|authentic for|legitimate for|valid for|sound for|solid for|strong for|robust for|tough for|durable for|lasting for|permanent for|enduring for|timeless for|classic for|traditional for|conventional for|standard for|regular for|normal for|typical for|usual for|common for|ordinary for|average for|mediocre for|fair for|decent for|respectable for|acceptable for|satisfactory for|adequate for|sufficient for|enough for|plentiful for|abundant for|ample for|generous for|plenty for|rich for|wealthy for|prosperous for|successful for|thriving for|flourishing for|blooming for|growing for|expanding for|developing for|improving for|better for|superior for|higher for|elevated for|advanced for|progressive for|modern for|contemporary for|current for|up to date for|latest for|new for|fresh for|novel for|innovative for|creative for|original for|unique for|different for|special for|extraordinary for|unusual for|rare for|uncommon for|exceptional for|outstanding for|remarkable for|notable for|memorable for|unforgettable for|legendary for|famous for|well known for|recognized for|acknowledged for|celebrated for|acclaimed for|honored for|awarded for|decorated for|distinguished for|illustrious for|prestigious for|reputable for|respected for|admired for|revered for|worshipped for|idolized for|beloved for|cherished for|treasured for|valued for|prized for|precious for|dear for|close for|intimate for|personal for|private for|individual for|unique for|special for|one of a kind for|irreplaceable for|invaluable for|priceless for|worthwhile for|valuable for|useful for|beneficial for|helpful for|advantageous for|profitable for|rewarding for|satisfying for|gratifying for|fulfilling for|complete for|whole for|total for|entire for|full for|perfect for|ideal for|ultimate for|best for|finest for|supreme for|excellent for|outstanding for|superior for|exceptional for|remarkable for|extraordinary for|special for|unique for|distinctive for|memorable for|impressive for|striking for|dramatic for|powerful for|strong for|effective for|efficient for|successful for|productive for|fruitful for|beneficial for|valuable for|useful for|helpful for|worthwhile for|rewarding for|satisfying for|gratifying for|fulfilling for} \ No newline at end of file +{Yeah|Yep|Yup|Yes|Absolutely|Definitely|Sure|Sounds|That's|I'm|I am|Totally|Completely|Right|Correct|Exactly|Perfectly|Certainly|Of course|Naturally|Indeed|Awesome|Sweet|Cool|Neat|Great|Excellent|Fantastic|Wonderful|Amazing|Love it|Nice|Right on|You bet|For sure|No doubt|Without a doubt|Undoubtedly|Positively|Surely|Truly|Really|Genuinely|Honestly|Frankly|Literally|Precisely|Spot on|On point|Ideally|Optimally|Superbly|Brilliantly|Marvelously|Splendidly|Magnificently|Phenomenally|Extraordinarily|Remarkably|Exceptionally|Outstandingly|Impressively|Stunningly|Breathtakingly|Astonishingly|Surprisingly|Pleasantly|Delightfully|Charmingly|Appealingly|Attractively|Invitingly|Encouragingly|Motivatingly|Inspiringly|Upliftingly|Positive|Optimistic|Supportive|Approving|Favorable|Enthusiastic|Eager|Willing|Ready|Prepared|Set|Go|Let's|Alright|Okay|Sure thing|No problem|You got it|Consider it done|Will do|Roger that|Copy that|Got it|Understood|Acknowledged|Noted|Confirmed|Agreed|Approved|Accepted|Endorsed|Backed|Championed} {sounds|looks|seems|feels|is|appears|comes across|strikes me|hits me|registers|resonates|clicks|makes sense|fits|works|functions|operates|performs|delivers|succeeds|achieves|accomplishes|excels|shines|stands out|impresses|satisfies|meets expectations|exceeds expectations|delights|pleases|gratifies|fulfills|completes|finishes|concludes|wraps up|finalizes|settles|resolves|solves|fixes|addresses|handles|manages|tackles|conquers|overcomes|defeats|beats|wins|triumphs|prevails|dominates|leads|guides|directs|steers|navigates|paves the way|opens doors|creates opportunities|makes possible|enables|allows|permits|facilitates|drives|pushes|propels|launches|initiates|starts|begins|commences|kicks off|gets going|moves forward|progresses|advances|develops|evolves|grows|expands|improves|enhances|upgrades|optimizes|refines|perfects|polishes} {good|great|perfect|excellent|wonderful|fantastic|amazing|awesome|fine|okay|alright|nice|cool|spot on|reasonable|about right|superb|brilliant|marvelous|splendid|magnificent|phenomenal|extraordinary|remarkable|exceptional|outstanding|impressive|stunning|breathtaking|astonishing|surprising|pleasant|delightful|charming|appealing|attractive|inviting|positive|optimistic|supportive|approving|favorable|enthusiastic|eager|willing|ready|prepared|set|solid|strong|robust|powerful|effective|efficient|productive|successful|fruitful|beneficial|valuable|useful|helpful|advantageous|profitable|rewarding|satisfying|gratifying|fulfilling|complete|whole|total|entire|full|thorough|comprehensive|exhaustive|detailed|precise|accurate|correct|right|true|valid|sound|logical|rational|practical|realistic|feasible|possible|doable|achievable|attainable|obtainable|reachable|accessible|available|present|arranged|organized|structured|planned|scheduled|timed|well positioned|strategically located|ideally situated|well suited|well matched|compatible|harmonious|balanced|proportional|symmetrical|aesthetic|beautiful|gorgeous|lovely|pretty|handsome|striking|dramatic|bold|confident|assertive|decisive|clear|obvious|apparent|evident|manifest|plain|simple|easy|straightforward|uncomplicated|complex|intricate|nuanced|subtle|refined|elegant|sophisticated|advanced|progressive|innovative|creative|original|unique|special|distinctive|memorable|unforgettable|significant|important|major|key|critical|essential|vital|crucial|fundamental|basic|primary|principal|main|chief|leading|top|best|finest|ultimate|supreme|paramount|foremost|world class|professional|expert|master|skilled|talented|gifted|intelligent|smart|clever|wise|knowledgeable|informed|educated|learned|scholarly|theoretical|practical|applied|hands on|experienced|seasoned|veteran|mature|visionary|prophetic|intuitive|perceptive|insightful|sage|profound|deep|meaningful|substantial|considerable|influential|resilient|tough|durable|lasting|permanent|enduring|timeless|classic|traditional|conventional|standard|regular|normal|typical|usual|common|ordinary|average|fair|decent|respectable|acceptable|satisfactory|adequate|sufficient|enough|plentiful|abundant|ample|generous|rich|wealthy|prosperous|thriving|flourishing|blooming|superior|higher|elevated|modern|contemporary|current|fresh|novel|rare|uncommon|legendary|famous|well known|celebrated|accredited|honored|awarded|decorated|distinguished|illustrious|prestigious|reputable|admired|revered|beloved|cherished|treasured|prized|precious|close|intimate|personal|private|individual|priceless|worthwhile} {to me|for me|with me|I agree|I like it|let's do it|count me in|I'm on board|I'm in|I'm up for it|I'm down for that|I'm all for it|I'm good with that|I'm happy with that|I'm cool with that|let's go with that|let's make it happen|that works|that'll work|sounds like a plan|that's a good idea|that's a great choice|I think so too|my thoughts exactly|you read my mind|couldn't agree more|absolutely right|you nailed it|let's go|game on|challenge accepted|say no more|you had me at hello|I'm sold|sign me up|be there|definitely|for sure|sounds good|looks good|seems good|feels good|is good|let's do this|time to rock|let's roll|here we go|off we go|moving forward|full steam ahead|all systems go|green light|clear for takeoff|ready when you are|on your mark|get set|let's begin|commence operation|initiate protocol|execute plan|implement strategy|deploy solution|activate system|engage process|start procedure|begin sequence|launch project|kick off event|open doors|make way|clear path|pave way|create opportunity|make possible|enable success|facilitate growth|support development|encourage progress|inspire change|motivate action|drive results|push boundaries|break barriers|overcome challenges|solve problems|fix issues|address concerns|handle situations|manage difficulties|tackle obstacles|conquer fears|defeat doubts|win battles|triumph over adversity|prevail against odds|rise above|excel beyond|achieve greatness|reach heights|attain goals|accomplish dreams|realize potential|fulfill destiny|complete journey|finish race|cross finish line|arrive at destination|reach summit|climb mountain|sail seas|fly skies|explore worlds|discover truths|find answers|solve mysteries|uncover secrets|reveal wonders|share insights|spread joy|create happiness|build relationships|strengthen bonds|foster community|grow together|learn constantly|improve daily|evolve continuously|adapt quickly|change rapidly|transform completely|renew fully|refresh completely|restart anew|begin again|start fresh|clean slate|new chapter|fresh start|bright future|promising tomorrow|better days|good times|great moments|wonderful experiences|fantastic adventures|amazing journeys|awesome memories|precious moments|valuable lessons|helpful advice|useful tips|practical solutions|effective strategies|successful methods|proven approaches|tested techniques|reliable systems|dependable support|consistent performance|steady progress|continuous improvement|ongoing development|perpetual growth|endless possibilities|unlimited potential|infinite opportunities|boundless horizons|vast expanses|wide ranges|broad spectrums|diverse options|multiple choices|various paths|different routes|alternative ways|other methods|additional approaches|extra techniques|supplementary tools|auxiliary resources|backup plans|contingency options|emergency measures|safety nets|security blankets|comfort zones|safe spaces|peaceful havens|tranquil sanctuaries|serene environments|calm atmospheres|relaxed vibes|easy feelings|comfortable sensations|pleasant experiences|enjoyable moments|delightful times|charming encounters|appealing situations|attractive prospects|inviting opportunities|encouraging signs|motivating factors|inspiring elements|uplifting aspects|positive features|optimistic views|encouraging outlooks|supportive attitudes|approving perspectives|favorable opinions|enthusiastic responses|eager reactions|willing participants|ready volunteers|prepared individuals|set teams|organized groups|structured units|planned initiatives|scheduled events|timed activities|well positioned assets|strategically located resources|ideally situated elements|perfectly suited components|well matched partners|compatible collaborations|harmonious relationships|balanced arrangements|proportional distributions|symmetrical designs|aesthetic presentations|beautiful displays|gorgeous exhibitions|lovely shows|pretty sights|attractive views|striking scenes|dramatic performances|bold statements|confident expressions|decisive actions|clear communications|obvious demonstrations|apparent revelations|evident truths|manifest realities|plain facts|simple solutions|easy implementations|straightforward processes|uncomplicated procedures|complex systems|intricate networks|detailed analyses|nuanced discussions|subtle distinctions|refined approaches|elegant solutions|sophisticated methods|advanced technologies|progressive ideas|innovative concepts|creative designs|original works|unique creations|special projects|distinctive features|memorable experiences|unforgettable moments|legendary achievements|famous accomplishments|well recognized contributions|acknowledged impacts|celebrated successes|acclaimed performances|honored achievements|awarded excellence|decorated heroes|distinguished leaders|illustrious careers|prestigious positions|reputable organizations|respected institutions|admired figures|revered icons|beloved personalities|cherished treasures|valued possessions|prized collections|precious artifacts|dear friends|close companions|intimate partners|personal connections|individual expressions|unique perspectives|special talents|one of a kind gifts|irreplaceable values|invaluable insights|priceless wisdom|worthwhile endeavors|valuable investments|useful tools|beneficial resources|helpful services|advantageous positions|profitable ventures|rewarding careers|satisfying lives|gratifying experiences|fulfilling purposes|complete beings|whole persons|total entities|entire systems|full cycles|perfect circles|ideal forms|ultimate goals|best practices|finest qualities|supreme achievements|excellent results|outstanding performances|superior outcomes|exceptional contributions|remarkable discoveries|extraordinary breakthroughs|special recognitions|unique innovations|distinctive designs|memorable impacts|impressive feats|dramatic transformations|powerful changes|strong foundations|effective actions|efficient operations|successful missions|productive endeavors|fruitful partnerships|beneficial collaborations|valuable connections|helpful networks|worthwhile projects|rewarding adventures|satisfying journeys|gratifying accomplishments|fulfilling destinies}{|!|, let's go!|, amazing!|, fantastic!|, wonderful!|, perfect!|, brilliant!|, excellent!|, outstanding!|, superb!|, great!|, nice!|, cool!|, sweet!|, awesome!|, love it!|, beautiful!|, gorgeous!|, stunning!|, breathtaking!|, phenomenal!|, extraordinary!|, remarkable!|, exceptional!|, impressive!|, striking!|, dramatic!|, powerful!|, magnificent!|, splendid!|, marvelous!|, terrific!|, superb!|, divine!|, heavenly!|, celestial!|, transcendent!|, sublime!|, perfect!|, flawless!|, impeccable!|, ideal!|, ultimate!|, supreme!|, paramount!|, unbeatable!|, unstoppable!|, incredible!|, unbelievable!|, astounding!|, mind-blowing!|, jaw-dropping!|, spectacular!|, epic!|, legendary!|, iconic!|, classic!|, timeless!|, eternal!|, infinite!|, boundless!|, limitless!|, endless!|, forever!|, always!|, never-ending!|, perpetual!|, constant!|, steady!|, solid!|, rock-solid!|, unshakeable!|, unbreakable!|, invincible!|, indestructible!|, immortal!|, everlasting!|, undying!|, living!|, vibrant!|, dynamic!|, energetic!|, lively!|, spirited!|, enthusiastic!|, passionate!|, fervent!|, zealous!|, dedicated!|, committed!|, devoted!|, loyal!|, faithful!|, true!|, real!|, authentic!|, genuine!|, legit!|, certified!|, proven!|, tested!|, verified!|, confirmed!|, validated!|, approved!|, endorsed!|, supported!|, backed!|, guaranteed!|, assured!|, certain!|, sure!|, positive!|, confident!|, secure!|, safe!|, protected!|, covered!|, sheltered!|, guarded!|, watched over!|, cared for!|, nurtured!|, cherished!|, treasured!|, valued!|, respected!|, admired!|, appreciated!|, recognized!|, acknowledged!|, celebrated!|, honored!|, praised!|, applauded!|, cheered!|, supported!|, embraced!|, welcomed!|, accepted!|, included!|, belonging!|, connected!|, united!|, joined!|, together!|, as one!|, in harmony!|, in sync!|, aligned!|, balanced!|, centered!|, grounded!|, rooted!|, established!|, settled!|, calm!|, peaceful!|, serene!|, tranquil!|, quiet!|, still!|, at ease!|, comfortable!|, relaxed!|, content!|, happy!|, joyful!|, delighted!|, thrilled!|, excited!|, elated!|, ecstatic!|, overjoyed!|, euphoric!|, blissful!|, radiant!|, glowing!|, shining!|, sparkling!|, dazzling!|, brilliant!|, bright!|, luminous!|, illuminated!|, enlightened!|, inspired!|, uplifted!|, elevated!|, empowered!|, strengthened!|, fortified!|, revitalized!|, renewed!|, refreshed!|, recharged!|, energized!|, activated!|, awakened!|, alive!|, thriving!|, flourishing!|, blooming!|, growing!|, expanding!|, developing!|, evolving!|, transforming!|, becoming!|, emerging!|, rising!|, ascending!|, climbing!|, reaching!|, achieving!|, succeeding!|, winning!|, triumphing!|, conquering!|, overcoming!|, mastering!|, perfecting!|, completing!|, fulfilling!|, realizing!|, manifesting!|, creating!|, building!|, making!|, doing!|, being!|, living!|, breathing!|, existing!|, present!|, here!|, now!|, always!|, forever!|, eternally!} \ No newline at end of file diff --git a/internal/honeypot/naive/naive.go b/internal/honeypot/naive/naive.go index 4d6a61e3..461d1d53 100644 --- a/internal/honeypot/naive/naive.go +++ b/internal/honeypot/naive/naive.go @@ -2,16 +2,19 @@ package naive import ( _ "embed" + "fmt" "log/slog" "math/rand/v2" "net/http" + "net/netip" "time" + "github.com/TecharoHQ/anubis/internal" "github.com/TecharoHQ/anubis/internal/honeypot" "github.com/TecharoHQ/anubis/lib/store" "github.com/a-h/templ" "github.com/google/uuid" - "github.com/m1/gospin" + "github.com/nikandfor/spintax" ) //go:generate go tool github.com/a-h/templ/cmd/templ generate @@ -31,52 +34,88 @@ var titles string //go:embed affirmations.txt var affirmations string -func New(st store.Interface, lg *slog.Logger) *Impl { - spin := gospin.New(nil) +func New(st store.Interface, lg *slog.Logger) (*Impl, error) { + affirmation, err := spintax.Parse(affirmations) + if err != nil { + return nil, fmt.Errorf("can't parse affirmations: %w", err) + } + + body, err := spintax.Parse(spintext) + if err != nil { + return nil, fmt.Errorf("can't parse bodies: %w", err) + } + + title, err := spintax.Parse(titles) + if err != nil { + return nil, fmt.Errorf("can't parse titles: %w", err) + } + + lg.Debug("initialized basic bullshit generator", "affirmations", affirmation.Count(), "bodies", body.Count(), "titles", title.Count()) return &Impl{ - st: st, - infos: store.JSON[honeypot.Info]{Underlying: st, Prefix: "honeypot-infos"}, - spin: spin, - lg: lg.With("component", "honeypot/naive"), - } + st: st, + infos: store.JSON[honeypot.Info]{Underlying: st, Prefix: "honeypot-infos"}, + affirmation: affirmation, + body: body, + title: title, + lg: lg.With("component", "honeypot/naive"), + }, nil } type Impl struct { st store.Interface infos store.JSON[honeypot.Info] - spin *gospin.Spinner lg *slog.Logger + + affirmation, body, title spintax.Spintax } func (i *Impl) makeAffirmations() []string { - result, err := i.spin.SpinN(affirmations, rand.IntN(5)+1) - if err != nil { - i.lg.Debug("can't spin affirmations, using fallback", "err", err) - return []string{uuid.NewString()} + count := rand.IntN(5) + 1 + + var result []string + for j := 0; j < count; j++ { + result = append(result, i.affirmation.Spin()) } return result } func (i *Impl) makeSpins() []string { - result, err := i.spin.SpinN(spintext, rand.IntN(8)+8) - if err != nil { - i.lg.Debug("can't spin text, using fallback", "err", err) - return []string{uuid.NewString()} + count := rand.IntN(5) + 1 + + var result []string + for j := 0; j < count; j++ { + result = append(result, i.body.Spin()) } return result } func (i *Impl) makeTitle() string { - result, err := i.spin.Spin(titles) - if err != nil { - i.lg.Debug("can't spin titles, using fallback", "err", err) - return uuid.NewString() - } + return i.title.Spin() +} - return result +func (i *Impl) clampIP(addr netip.Addr) netip.Prefix { + fallback := netip.MustParsePrefix(addr.String() + "/32") + switch { + case addr.Is4() || addr.Is4In6(): + result, err := addr.Prefix(24) + if err != nil { + return fallback + } + return result + + case addr.Is6(): + result, err := addr.Prefix(48) + if err != nil { + return fallback + } + return result + + default: + return fallback + } } func (i *Impl) ServeHTTP(w http.ResponseWriter, r *http.Request) { @@ -87,9 +126,45 @@ func (i *Impl) ServeHTTP(w http.ResponseWriter, r *http.Request) { id = uuid.NewString() } + realIP, _ := internal.RealIP(r) + if !realIP.IsValid() { + i.lg.Error("the real IP is somehow invalid, bad middleware stack?") + http.Error(w, "The cake is a lie", http.StatusTeapot) + return + } + + network := i.clampIP(realIP) + stage := r.PathValue("stage") + + var info honeypot.Info + var err error + if stage == "init" { - i.lg.Debug("found new entrance point", "id", id, "userAgent", r.UserAgent(), "ip", r.Header.Get("X-Real-Ip")) + i.lg.Debug("found new entrance point", "id", id, "userAgent", r.UserAgent(), "clampedIP", network) + + info = honeypot.Info{ + CreatedAt: time.Now(), + UserAgent: r.UserAgent(), + IPAddress: realIP.String(), + HitCount: 1, + } + + i.infos.Set(r.Context(), network.String(), info, time.Hour) + } else { + info, err = i.infos.Get(r.Context(), network.String()) + if err != nil { + info = honeypot.Info{ + CreatedAt: time.Now(), + UserAgent: r.UserAgent(), + IPAddress: realIP.String(), + HitCount: 1, + } + i.infos.Set(r.Context(), network.String(), info, time.Hour) + } else { + info.HitCount++ + i.infos.Set(r.Context(), network.String(), info, time.Hour) + } } spins := i.makeSpins() diff --git a/internal/honeypot/naive/page.templ b/internal/honeypot/naive/page.templ index fdf65c2a..eb3ccec4 100644 --- a/internal/honeypot/naive/page.templ +++ b/internal/honeypot/naive/page.templ @@ -30,7 +30,7 @@ templ (i Impl) maze(body []string, links []link) { }