Temporary Advertisements:
Ad
Ad
Ad
[HTB] The "like a glove" ai-ml challenge
by TEA19896446 - Sunday August 18, 2024 at 05:30 AM
#1
pip install gensim

import gensim.downloader as api

model=api.loade(glove-twitter-25)
......
model.most_similar(positive=[y,z], negative=[x], topn=1)
......

But only got htb and {, the follow chars seems not correct, any hints?
Reply
#2
did anyone get this
Reply
#3
Your model is not correct.
```
vec1 = model[word1]
vec2 = model[word2]
vec_target = model[target]

analogy_vector = vec_target + (vec2 - vec1)

result = model.similar_by_vector(analogy_vector, topn=1)
```
Reply
#4
(Aug 18, 2024, 03:35 PM)axcqwrq Wrote: Your model is not correct.
```
            vec1 = model[word1]
            vec2 = model[word2]
            vec_target = model[target]

            analogy_vector = vec_target + (vec2 - vec1)

            result = model.similar_by_vector(analogy_vector, topn=1)
```

Yes! It works Heart Heart Heart
Reply
#5
mine is working too thanks Big Grin
Reply
#6
import gensim.downloader as api
import re
import string

# Load the GloVe model
model = api.load("glove-twitter-25")

# File path to the challenge file
file_path = "chal.txt"

flag = ""

# Mapping full-width characters to ASCII
full_width_map = {
    "0": "0",
    "1": "1",
    "2": "2",
    "3": "3",
    "4": "4",
    "5": "5",
    "6": "6",
    "7": "7",
    "8": "8",
    "9": "9",
}


# Helper function to keep only ASCII characters, digits, punctuation, and whitespace
def keep_ascii_and_digits(text):
    normalized_text = "".join(full_width_map.get(c, c) for c in text)
    return "".join(
        c
        for c in normalized_text
        if c
        in string.ascii_letters + string.digits + string.punctuation + string.whitespace
    )


# Regex pattern to capture the analogy components
pattern = re.compile(r"^Like ([^\s]+) is to ([^\s]+), ([^\s]+) is to\?$")

# Read each line from chall.txt and calculate the analogy
with open(file_path, "r") as file:
    for line in file:
        try:
            # Use regex to extract words from the line
            match = pattern.match(line.strip())
            if not match:
                print(f"Skipping line due to incorrect format: {line}")
                continue

            word1, word2_target, target = match.groups()

            vec1 = model[word1]
            vec2 = model[word2_target]
            vec_target = model[target]

            analogy_vector = vec_target + (vec2 - vec1)
            result = model.similar_by_vector(analogy_vector, topn=1)
            result_word = keep_ascii_and_digits(result[0][0])
            print(
                f"Target word for analogy '{target}' ({word2_target} - {word1} + {target}): {result_word}"
            )
            flag += result_word
        except KeyError as e:
            print(f"Word not found in model: {e}")

print(f"[+] Flag: {flag}")
Reply
#7
wow, many thanks for the writeup
Reply
#8
dude you saved me

This forum account is currently banned. Ban Length: Permanent (N/A Remaining)
Ban Reason: Leeching | http://c66go4clkqodr7tdjfu76jztjs7w7d3fajdeypxn73v4ju3dt7g5yyyd.onion/Forum-Ban-Appeals if you feel this is incorrect.
Reply
#9
THANK YOU! I can't believe how close and also NOT close I was <3
Reply
#10
WOW, thanks for the writeup, dude!
That's great!
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  WE ARE BACK JUST LIKE LEGENDZFORUM GUYZ.OUR TELEGRAM https://t.me/rayhush Hit me up goagaintodds 0 86 Yesterday, 04:25 PM
Last Post: goagaintodds
  [FREE] 300+ Writeups PDF HackTheBox/HTB premium retired Tamarisk 457 122,129 Yesterday, 05:21 AM
Last Post: jiqmug
  [MEGALEAK] HackTheBox ProLabs, Fortress, Endgame - Alchemy, 250 Flags, leak htb-bot htb-bot 166 35,109 Yesterday, 03:09 AM
Last Post: meomeothantai
  CC,CVV,VBV,NON VBV ,DUMPS ,FULLZ,BANK LOGS (FULL INFO) BEST LINKABLES @RICKBUTLER Ballerwailer4G 0 134 Oct 18, 2026, 11:06 PM
Last Post: Ballerwailer4G
  [FREE] HackTheBox Academy - CBBH CDSA CPTS All Modules Flags Techtom 110 14,515 Oct 18, 2026, 06:21 PM
Last Post: Kazahk

Forum Jump:


 Users browsing this forum: