Skip to content

Instantly share code, notes, and snippets.

@miketartar
Created September 26, 2020 04:21
Show Gist options
  • Select an option

  • Save miketartar/0fc8d7bca2369ce73ea9ee7b6e0c3775 to your computer and use it in GitHub Desktop.

Select an option

Save miketartar/0fc8d7bca2369ce73ea9ee7b6e0c3775 to your computer and use it in GitHub Desktop.
Cold Turkey Blocker Activator
import json
import sqlite3
import os
DB_PATH = "C:/ProgramData/Cold Turkey/data-app.db"
def activate():
try:
conn = sqlite3.connect(DB_PATH)
c = conn.cursor()
s = c.execute("SELECT value FROM settings WHERE key = 'settings'").fetchone()[0]
dat = json.loads(s)
if dat["additional"]["proStatus"] != "pro":
print("Your version of Cold Turkey Blocker is not activated.")
dat["additional"]["proStatus"] = "pro"
print("But now it is activated.\nPlease close Cold Turkey Blocker and run again it.")
c.execute("""UPDATE settings SET value = ? WHERE "key" = 'settings'""", (json.dumps(dat),))
conn.commit()
else:
print("Looks like your copy of Cold Turkey Blocker is already activated.")
print("Deactivating it now.")
dat["additional"]["proStatus"] = "free"
c.execute("""UPDATE settings set value = ? WHERE "key" = 'settings'""", (json.dumps(dat),))
conn.commit()
except sqlite3.Error as e:
print("Failed to activate", e)
finally:
if conn:
conn.close()
def main():
if os.path.exists(DB_PATH):
print("Data file found.\nLet's activate your copy of Cold Turkey Blocker.")
activate()
else:
print("Looks like Cold Turkey Blocker is not installed.\n If it is installed then run it at least once.")
if __name__ == '__main__':
main()
@niecemiece-code
Copy link
Copy Markdown

This script works for the latest version (4.9):

import json
import sqlite3

DB_PATH = "C:/ProgramData/Cold Turkey/data-app.db"

def decode(s):
    data = s[5:]
    return ''.join(chr(int(data[i:i+2], 16) - 0x11) for i in range(0, len(data), 2))

def encode(s):
    return "CTB17" + ''.join(f'{ord(c) + 0x11:02X}' for c in s)

conn = sqlite3.connect(DB_PATH)
c = conn.cursor()
raw = c.execute("SELECT value FROM settings WHERE key = 'settings'").fetchone()[0]
dat = json.loads(decode(raw))
dat["additional"]["proStatus"] = "free" if dat["additional"]["proStatus"] == "pro" else "pro"
c.execute("UPDATE settings SET value = ? WHERE key = 'settings'", (encode(json.dumps(dat)),))
conn.commit()
conn.close()
print("Toggled to:", dat["additional"]["proStatus"])

Working as of 2/4/26 ily brotato

@svalordev
Copy link
Copy Markdown

Thank you so much guys for this 🙏😭

@Skibbyskib
Copy link
Copy Markdown

Thank you so much it works

@RajDas099
Copy link
Copy Markdown

This script works for the latest version (4.9):

import json
import sqlite3

DB_PATH = "C:/ProgramData/Cold Turkey/data-app.db"

def decode(s):
    data = s[5:]
    return ''.join(chr(int(data[i:i+2], 16) - 0x11) for i in range(0, len(data), 2))

def encode(s):
    return "CTB17" + ''.join(f'{ord(c) + 0x11:02X}' for c in s)

conn = sqlite3.connect(DB_PATH)
c = conn.cursor()
raw = c.execute("SELECT value FROM settings WHERE key = 'settings'").fetchone()[0]
dat = json.loads(decode(raw))
dat["additional"]["proStatus"] = "free" if dat["additional"]["proStatus"] == "pro" else "pro"
c.execute("UPDATE settings SET value = ? WHERE key = 'settings'", (encode(json.dumps(dat)),))
conn.commit()
conn.close()
print("Toggled to:", dat["additional"]["proStatus"])

HEROOO!!!

@RajDas099
Copy link
Copy Markdown

It worked for the latest 4.9

@Benjamin9864
Copy link
Copy Markdown

Why wouldnt this work on mac?? ˙◠˙

@M1NGJ0
Copy link
Copy Markdown

M1NGJ0 commented Mar 11, 2026

For people who are having trouble because the link for 4.5 is down. I have created a step by step guide:

Step 1:
Keep your Cold Turkey Version 4.9 and open notepad

Step 2:
Create a new note and paste this in:
import json
import sqlite3

DB_PATH = "C:/ProgramData/Cold Turkey/data-app.db"

def decode(s):
data = s[5:]
return ''.join(chr(int(data[i:i+2], 16) - 0x11) for i in range(0, len(data), 2))

def encode(s):
return "CTB17" + ''.join(f'{ord(c) + 0x11:02X}' for c in s)

conn = sqlite3.connect(DB_PATH)
c = conn.cursor()
raw = c.execute("SELECT value FROM settings WHERE key = 'settings'").fetchone()[0]
dat = json.loads(decode(raw))
dat["additional"]["proStatus"] = "free" if dat["additional"]["proStatus"] == "pro" else "pro"
c.execute("UPDATE settings SET value = ? WHERE key = 'settings'", (encode(json.dumps(dat)),))
conn.commit()
conn.close()
print("Toggled to:", dat["additional"]["proStatus"])

After that, press ctrl,shift,s and save in downloads as main,py as the name.

VERY IMPORTANT STEP or it won't work: you have to go to task manager and end cold turkey as the task and after you have run the code and it said toggled to pro, only then you open cold turkey and it will work
go to command prompt and type this, py main.py it will say toggled to pro and there you go, you have a pro version of cold turkey for free. THANK YOU SO MUCH to @Someone45 because he was the one who had the updated code and gave it to us

@inamorously
Copy link
Copy Markdown

Doesn't seem to be an equivalent file for data-app.db on macos. Am I stupid? Help

@anonymous-rat
Copy link
Copy Markdown

Doesn't seem to be an equivalent file for data-app.db on macos. Am I stupid? Help

"/Library/Application Support/Cold Turkey/data-app.db"

@AlfaroT
Copy link
Copy Markdown

AlfaroT commented Mar 19, 2026

para la versión 4.9

`import json
import os
import sqlite3

DB_PATH = r"C:\ProgramData\Cold Turkey\data-app.db"

def decode_data(encoded_string):
if not encoded_string.startswith("CTB"):
# Si no está codificado, devolverlo como está
return encoded_string
hex_data = encoded_string[3:]
byte_data = bytes.fromhex(hex_data)
# La operación correcta es una suma con 239 (o resta con 17)
decoded_bytes = bytes([(b + 239) & 0xFF for b in byte_data])
# Omitir el primer byte que parece ser un prefijo
return decoded_bytes[1:].decode('utf-8')

def encode_data(decoded_string):
# Añadir el prefijo de nuevo
decoded_bytes = (b'\x06' + decoded_string.encode('utf-8'))
# La operación inversa es una resta con 239 (o suma con 17)
encoded_bytes = bytes([(b - 239) & 0xFF for b in decoded_bytes])
hex_data = encoded_bytes.hex().upper()
return "CTB" + hex_data

def activate():
conn = None
try:
conn = sqlite3.connect(DB_PATH)
c = conn.cursor()

    row = c.execute("SELECT value FROM settings WHERE key = 'settings'").fetchone()
    if row is None:
        print("Error: no se encontró la fila de configuración en la base de datos.")
        return

    s = row[0]
    
    try:
        if s.startswith("CTB"):
            decoded_s = decode_data(s)
            dat = json.loads(decoded_s)
            is_encoded = True
        else:
            dat = json.loads(s)
            is_encoded = False
    except (json.JSONDecodeError, UnicodeDecodeError) as e:
        print(f"No se pudo decodificar la configuración: {e}")
        return

    current = dat.get("additional", {}).get("proStatus")
    if current != "pro":
        print("Tu versión de Cold Turkey Blocker no está activada.")
        dat.setdefault("additional", {})["proStatus"] = "pro"
        new_value = json.dumps(dat)
        if is_encoded:
            new_value = encode_data(new_value)
        
        c.execute(
            "UPDATE settings SET value = ? WHERE key = 'settings'",
            (new_value,),
        )
        conn.commit()
        print("Ahora está activado. Por favor, cierra Cold Turkey Blocker y vuelve a ejecutarlo.")
    else:
        print("Parece que tu copia de Cold Turkey Blocker ya está activada.\nDesactivándola ahora.")
        dat["additional"]["proStatus"] = "free"
        new_value = json.dumps(dat)
        if is_encoded:
            new_value = encode_data(new_value)

        c.execute(
            "UPDATE settings SET value = ? WHERE key = 'settings'",
            (new_value,),
        )
        conn.commit()
        print("Ahora está desactivado.")

except sqlite3.Error as e:
    print("Fallo al actualizar la base de datos de Cold Turkey Blocker:", e)
except Exception as e:
    print("Error inesperado:", e)
finally:
    if conn:
        conn.close()

def main():
if os.path.exists(DB_PATH):
print("Archivo de datos encontrado. Vamos a activar tu copia de Cold Turkey Blocker.")
activate()
else:
print(
"Parece que Cold Turkey Blocker no está instalado. Si está instalado, ejecútalo al menos una vez."
)

if name == "main":
main()
`

@gsmuhandiram
Copy link
Copy Markdown

It's amazing that this still works. And guys after doing this once exit the app right clicking on the bottom right taskbar icon and reopen the app. You will see the pro then. Cheers! :)

@codename-five
Copy link
Copy Markdown

Is anyone having the issue of blocks restarting before they're supposed to? For example, I have an "Entertainment" blocklist with YouTube, Reddit, etc. It's blocked at all times, but to unblock it, I can type 400 words and set how long I want to unblock it, e.g., 2 hours, 4 hours, etc. After using this script, the block randomly locks itself before the time is up. It's frustrating. Toggling back to free hasn't solved this.

@cybermad47
Copy link
Copy Markdown

For people who are having trouble because the link for 4.5 is down. I have created a step by step guide:

Step 1: Keep your Cold Turkey Version 4.9 and open notepad

Step 2: Create a new note and paste this in: import json import sqlite3

DB_PATH = "C:/ProgramData/Cold Turkey/data-app.db"

def decode(s): data = s[5:] return ''.join(chr(int(data[i:i+2], 16) - 0x11) for i in range(0, len(data), 2))

def encode(s): return "CTB17" + ''.join(f'{ord(c) + 0x11:02X}' for c in s)

conn = sqlite3.connect(DB_PATH) c = conn.cursor() raw = c.execute("SELECT value FROM settings WHERE key = 'settings'").fetchone()[0] dat = json.loads(decode(raw)) dat["additional"]["proStatus"] = "free" if dat["additional"]["proStatus"] == "pro" else "pro" c.execute("UPDATE settings SET value = ? WHERE key = 'settings'", (encode(json.dumps(dat)),)) conn.commit() conn.close() print("Toggled to:", dat["additional"]["proStatus"])

After that, press ctrl,shift,s and save in downloads as main,py as the name.

VERY IMPORTANT STEP or it won't work: you have to go to task manager and end cold turkey as the task and after you have run the code and it said toggled to pro, only then you open cold turkey and it will work go to command prompt and type this, py main.py it will say toggled to pro and there you go, you have a pro version of cold turkey for free. THANK YOU SO MUCH to @Someone45 because he was the one who had the updated code and gave it to us

it works for me

@LightTriadCEM
Copy link
Copy Markdown

I put py main.py in the command but ":\Users\chris\AppData\Local\Programs\Python\Python314\python.exe: can't open file 'C:\Users\chris\main.py': [Errno 2] No such file or directory" just pops up

@siddhantlamichhane43-alt
Copy link
Copy Markdown

This script works for the latest version (4.9):

import json
import sqlite3

DB_PATH = "C:/ProgramData/Cold Turkey/data-app.db"

def decode(s):
    data = s[5:]
    return ''.join(chr(int(data[i:i+2], 16) - 0x11) for i in range(0, len(data), 2))

def encode(s):
    return "CTB17" + ''.join(f'{ord(c) + 0x11:02X}' for c in s)

conn = sqlite3.connect(DB_PATH)
c = conn.cursor()
raw = c.execute("SELECT value FROM settings WHERE key = 'settings'").fetchone()[0]
dat = json.loads(decode(raw))
dat["additional"]["proStatus"] = "free" if dat["additional"]["proStatus"] == "pro" else "pro"
c.execute("UPDATE settings SET value = ? WHERE key = 'settings'", (encode(json.dumps(dat)),))
conn.commit()
conn.close()
print("Toggled to:", dat["additional"]["proStatus"])

Bro thankyou so much. Still works on 04/11

@LightTriadCEM
Copy link
Copy Markdown

c.execute("UPDATE settings SET value = ? WHERE key = 'settings'", (encode(json.dumps(dat)),))

how did you do it

@piefit2020
Copy link
Copy Markdown

works as of 16/04/2026

@SSoggyTacoMan
Copy link
Copy Markdown

macos?

@zeyad-shaban
Copy link
Copy Markdown

This script works for the latest version (4.9):

import json
import sqlite3

DB_PATH = "C:/ProgramData/Cold Turkey/data-app.db"

def decode(s):
    data = s[5:]
    return ''.join(chr(int(data[i:i+2], 16) - 0x11) for i in range(0, len(data), 2))

def encode(s):
    return "CTB17" + ''.join(f'{ord(c) + 0x11:02X}' for c in s)

conn = sqlite3.connect(DB_PATH)
c = conn.cursor()
raw = c.execute("SELECT value FROM settings WHERE key = 'settings'").fetchone()[0]
dat = json.loads(decode(raw))
dat["additional"]["proStatus"] = "free" if dat["additional"]["proStatus"] == "pro" else "pro"
c.execute("UPDATE settings SET value = ? WHERE key = 'settings'", (encode(json.dumps(dat)),))
conn.commit()
conn.close()
print("Toggled to:", dat["additional"]["proStatus"])

Thank you bro!

@aidenjcheng
Copy link
Copy Markdown

aidenjcheng commented Apr 21, 2026

works on mac v4.9 if you just switch the DB_PATH to DB_PATH = "/Library/Application Support/Cold Turkey/data-app.db"

close and reopen it a couple times and it should work with activity monitor

This script works for the latest version (4.9):

import json
import sqlite3

DB_PATH = "C:/ProgramData/Cold Turkey/data-app.db"

def decode(s):
    data = s[5:]
    return ''.join(chr(int(data[i:i+2], 16) - 0x11) for i in range(0, len(data), 2))

def encode(s):
    return "CTB17" + ''.join(f'{ord(c) + 0x11:02X}' for c in s)

conn = sqlite3.connect(DB_PATH)
c = conn.cursor()
raw = c.execute("SELECT value FROM settings WHERE key = 'settings'").fetchone()[0]
dat = json.loads(decode(raw))
dat["additional"]["proStatus"] = "free" if dat["additional"]["proStatus"] == "pro" else "pro"
c.execute("UPDATE settings SET value = ? WHERE key = 'settings'", (encode(json.dumps(dat)),))
conn.commit()
conn.close()
print("Toggled to:", dat["additional"]["proStatus"])

@Penguinators
Copy link
Copy Markdown

Thank you much worked perfectly!

@samrza
Copy link
Copy Markdown

samrza commented Apr 29, 2026

can anyone help, i am bit confused , i have created a file main.py added above code , DB_PATH = "/Library/Application Support/Cold Turkey/data-app.db" , an dafter that run that file from terminal it said toggled to : pro, but why in cold turkey app i am not able to use pro feature like blocking apps, please help anyone

@Krystallos-official
Copy link
Copy Markdown

If the previous version is not working, try this:

  1. Install Cold Turkey Blocker from its official website.

  2. After installation, make sure the application is completely closed:

    • Check the system tray (hidden icons on the taskbar).
    • Right-click the icon and exit the application.
  3. Open Notepad (or any text editor).

  4. Paste the following code:

import json
import sqlite3

DB_PATH = "C:/ProgramData/Cold Turkey/data-app.db"

def decode(s):
    data = s[5:]
    return ''.join(chr(int(data[i:i+2], 16) - 0x11) for i in range(0, len(data), 2))

def encode(s):
    return "CTB17" + ''.join(f'{ord(c) + 0x11:02X}' for c in s)

conn = sqlite3.connect(DB_PATH)
c = conn.cursor()

raw = c.execute("SELECT value FROM settings WHERE key = 'settings'").fetchone()[0]

# Handle both formats (encoded and plain JSON)
if raw.startswith("CTB17"):
    dat = json.loads(decode(raw))
    use_encode = True
else:
    dat = json.loads(raw)
    use_encode = False

dat["additional"]["proStatus"] = (
    "free" if dat["additional"]["proStatus"] == "pro" else "pro"
)

new_value = json.dumps(dat)
if use_encode:
    new_value = encode(new_value)

c.execute("UPDATE settings SET value = ? WHERE key = 'settings'", (new_value,))
conn.commit()
conn.close()

print("Toggled to:", dat["additional"]["proStatus"])
  1. Save the file as:
main.py
  1. Open Command Prompt as Administrator.

  2. Navigate to the folder where you saved the file:

cd path\to\your\folder
  1. Run the script:
py main.py

@samrza
Copy link
Copy Markdown

samrza commented May 3, 2026

perfectly worked in windows but bro i am using mac one issue i am facing is how to completely close a app in background , i see in activity monitor its always running even after quit , i got toggles pro in terminal but nothing happened

@Shankar331505
Copy link
Copy Markdown

perfectly worked in windows but bro i am using mac one issue i am facing is how to completely close a app in background , i see in activity monitor its always running even after quit , i got toggles pro in terminal but nothing happened

press option + command + esc to force quit

@Shankar331505
Copy link
Copy Markdown

Use any IDE to create the python file like VS code or antigravity.

@samrza
Copy link
Copy Markdown

samrza commented May 8, 2026

hey all the man here helped me thanks to all wholeheartedly , as of 8th may 2026 cold turkey v4.9 it working completely fine on mac m2, when i will get money i will surely pay to this developer as a thanks

@siddhantlamichhane43-alt
Copy link
Copy Markdown

I put py main.py in the command but ":\Users\chris\AppData\Local\Programs\Python\Python314\python.exe: can't open file 'C:\Users\chris\main.py': [Errno 2] No such file or directory" just pops up

You saved in wrong location. navigate whare you have saved the file. First, save that py file in downloads and then paste this in cmd
cd /d "%userprofile%\Downloads"
Then Type py main.py It'll work

@AneebRasool
Copy link
Copy Markdown

I had a lot of problems running this code but there were many indentation problems. what I did to make it work exactly:

download latest version of cold turkey from website (4.9)
download python (if you havent already)

paste this to notepad:

import json
import sqlite3

DB_PATH = "C:/ProgramData/Cold Turkey/data-app.db"

def decode(s):
data = s[5:]
return ''.join(chr(int(data[i:i+2], 16) - 0x11) for i in range(0, len(data), 2))

def encode(s):
return "CTB17" + ''.join(f'{ord(c) + 0x11:02X}' for c in s)

conn = sqlite3.connect(DB_PATH)
c = conn.cursor()
raw = c.execute("SELECT value FROM settings WHERE key = 'settings'").fetchone()[0]
dat = json.loads(decode(raw))
dat["additional"]["proStatus"] = "free" if dat["additional"]["proStatus"] == "pro" else "pro"
c.execute("UPDATE settings SET value = ? WHERE key = 'settings'", (encode(json.dumps(dat)),))
conn.commit()
conn.close()
print("Toggled to:", dat["additional"]["proStatus"])

(ALSO: make sure to save in notepad, not as txt but under all files type in "main.py" and enter.
now use admin version of cmd, type in cd (your directory, ex C:\Users(your user)\Downloads
then type in py main.py and it should work

@naveganth
Copy link
Copy Markdown

If the previous version is not working, try this:

  1. Install Cold Turkey Blocker from its official website.

  2. After installation, make sure the application is completely closed:

    • Check the system tray (hidden icons on the taskbar).
    • Right-click the icon and exit the application.
  3. Open Notepad (or any text editor).

  4. Paste the following code:

import json
import sqlite3

DB_PATH = "C:/ProgramData/Cold Turkey/data-app.db"

def decode(s):
    data = s[5:]
    return ''.join(chr(int(data[i:i+2], 16) - 0x11) for i in range(0, len(data), 2))

def encode(s):
    return "CTB17" + ''.join(f'{ord(c) + 0x11:02X}' for c in s)

conn = sqlite3.connect(DB_PATH)
c = conn.cursor()

raw = c.execute("SELECT value FROM settings WHERE key = 'settings'").fetchone()[0]

# Handle both formats (encoded and plain JSON)
if raw.startswith("CTB17"):
    dat = json.loads(decode(raw))
    use_encode = True
else:
    dat = json.loads(raw)
    use_encode = False

dat["additional"]["proStatus"] = (
    "free" if dat["additional"]["proStatus"] == "pro" else "pro"
)

new_value = json.dumps(dat)
if use_encode:
    new_value = encode(new_value)

c.execute("UPDATE settings SET value = ? WHERE key = 'settings'", (new_value,))
conn.commit()
conn.close()

print("Toggled to:", dat["additional"]["proStatus"])
  1. Save the file as:
main.py
  1. Open Command Prompt as Administrator.
  2. Navigate to the folder where you saved the file:
cd path\to\your\folder
  1. Run the script:
py main.py

This is the only one working in the latest version, just download the Cold Turkey from the official website.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment