Find flag
This commit is contained in:
parent
4baeabb263
commit
e1af5acd3f
21
webcrawler
21
webcrawler
|
@ -1,8 +1,12 @@
|
||||||
#!/usr/bin/env racket
|
#!/usr/bin/env racket
|
||||||
#lang racket
|
#lang racket
|
||||||
; vim: ft=racket
|
; vim: ft=racket
|
||||||
|
(require xml)
|
||||||
(require smol-http)
|
(require smol-http)
|
||||||
|
|
||||||
|
;; scheme is bad and it should feel bad
|
||||||
|
(define member? member)
|
||||||
|
|
||||||
(define DEFAULT-HDRS '((user-agent . "🦈 hash-lang-uwu crawler v1.0")
|
(define DEFAULT-HDRS '((user-agent . "🦈 hash-lang-uwu crawler v1.0")
|
||||||
;; christo pls do not track thanks
|
;; christo pls do not track thanks
|
||||||
(dnt . "1")))
|
(dnt . "1")))
|
||||||
|
@ -28,6 +32,23 @@
|
||||||
(define (cookie-jar->header jar)
|
(define (cookie-jar->header jar)
|
||||||
(call-with-semaphore (cj-sema jar) (curry unbox (cj-cache jar))))
|
(call-with-semaphore (cj-sema jar) (curry unbox (cj-cache jar))))
|
||||||
|
|
||||||
|
(define test-data
|
||||||
|
(xml->xexpr
|
||||||
|
(document-element
|
||||||
|
(read-xml (open-input-string
|
||||||
|
"<doc><bold>hi<h2 class='secret_flag' style='color:red'>FLAG: 64-characters-of-random-alphanumerics</h2></bold> there!</doc>")))))
|
||||||
|
|
||||||
|
(define (find-flag xexpr)
|
||||||
|
(match xexpr
|
||||||
|
[(list _ (? (curry member? '(class "secret_flag"))) str)
|
||||||
|
str]
|
||||||
|
[(list tag params rst ...)
|
||||||
|
(ormap find-flag rst)]
|
||||||
|
[_ #f]))
|
||||||
|
|
||||||
|
(find-flag test-data)
|
||||||
|
|
||||||
|
|
||||||
(define debug-mode? (make-parameter #f))
|
(define debug-mode? (make-parameter #f))
|
||||||
(define current-cookie-jar (make-parameter (make-cookie-jar)))
|
(define current-cookie-jar (make-parameter (make-cookie-jar)))
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue