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()
@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

aidenjcheng commented Apr 21, 2026

Copy link
Copy Markdown

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

samrza commented Apr 29, 2026

Copy link
Copy Markdown

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

samrza commented May 3, 2026

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

@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

samrza commented May 8, 2026

Copy link
Copy Markdown

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.

@OmkarGharat

OmkarGharat commented May 30, 2026

Copy link
Copy Markdown

Final Working Script

Thank me later

import json
import sqlite3

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

def decode(s):
    # Remove the CTB17 prefix and any whitespace/newlines
    data = s[5:].strip()
    
    # Ensure an even number of hex characters
    if len(data) % 2 != 0:
        data = data[:-1]
        
    result = []
    for i in range(0, len(data), 2):
        hex_pair = data[i:i+2]
        try:
            val = int(hex_pair, 16) - 0x11
            if 0 <= val <= 0x10FFFF:  # Valid Unicode range
                result.append(chr(val))
        except ValueError:
            continue  # Skip invalid hex pairs
            
    return ''.join(result)

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"])

@ak5hiit

ak5hiit commented Jun 2, 2026

Copy link
Copy Markdown

Final Working Script

Thank me later

import json
import sqlite3

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

def decode(s):
    # Remove the CTB17 prefix and any whitespace/newlines
    data = s[5:].strip()
    
    # Ensure an even number of hex characters
    if len(data) % 2 != 0:
        data = data[:-1]
        
    result = []
    for i in range(0, len(data), 2):
        hex_pair = data[i:i+2]
        try:
            val = int(hex_pair, 16) - 0x11
            if 0 <= val <= 0x10FFFF:  # Valid Unicode range
                result.append(chr(val))
        except ValueError:
            continue  # Skip invalid hex pairs
            
    return ''.join(result)

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"])

this finally works for me. I was previously getting indentation errors but now it works perfectly fine. thanks!

@Wehsuh-Sushi

Copy link
Copy Markdown

@ak5hiit is the GOAT frfr saving us the hassle with these indentation errors

@Thiag07

Thiag07 commented Jun 12, 2026

Copy link
Copy Markdown

Final Working Script

Thank me later

import json
import sqlite3

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

def decode(s):
    # Remove the CTB17 prefix and any whitespace/newlines
    data = s[5:].strip()
    
    # Ensure an even number of hex characters
    if len(data) % 2 != 0:
        data = data[:-1]
        
    result = []
    for i in range(0, len(data), 2):
        hex_pair = data[i:i+2]
        try:
            val = int(hex_pair, 16) - 0x11
            if 0 <= val <= 0x10FFFF:  # Valid Unicode range
                result.append(chr(val))
        except ValueError:
            continue  # Skip invalid hex pairs
            
    return ''.join(result)

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"])

Thank you so much man

@drke3

drke3 commented Jun 14, 2026

Copy link
Copy Markdown

mac users change DB_PATH to:
DB_PATH = "/Library/Application Support/Cold Turkey/data-app.db"

@DevilRNK

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

I am having the error :

C:\Users\Rup>py main.py
File "C:\Users\Rup\main.py", line 7
data = s[5:]
^^^^
IndentationError: expected an indented block after function definition on line 6

@qwerty0466

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"])

W

@MakeSake

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

@MakeSake

Copy link
Copy Markdown

yo thanks a lot it works on 22/6

@gui-analyst

gui-analyst commented Jun 25, 2026

Copy link
Copy Markdown

Could someone help me with a step-by-step guide for Windows 11? I don't have much programming experience and didn't understand how to carry out the procedure. (version 4.9). I tried using AI to help me with this, but for ethical reasons they told me they won't help me with it.

@ayoubstudy2009-ops

Copy link
Copy Markdown

Could someone help me with a step-by-step guide for Windows 11? I don't have much programming experience and didn't understand how to carry out the procedure. (version 4.9). I tried using AI to help me with this, but for ethical reasons they told me they won't help me with it.

First install python (you can ask ai to help with that)

Create a folder name it cold turkey activator or anything really doesn't matter

Create a new python file OR create a new text file and edit the .txt to .py, after naming it exactly: "ColdTurkeyBlockerActivator" so you have a file named: ColdTurkeyBlockerActivator.py

in that folder right click any empty space and choose "open in terminal"

after opening terminal type: "py ColdTurkeyBlockerActivator.py"

after that restart coldturkey and pro should be toggled

@raffaelcopy2005

Copy link
Copy Markdown

For older versions where the DB is plain JSON (not CTB17 encoded), the script above throws a ValueError. Here's a version that auto-detects the format and works for both:

import json
import sqlite3

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

def decode(s):
    if s.startswith("CTB17"):
        data = s[5:]
        return ''.join(chr(int(data[i:i+2], 16) - 0x11) for i in range(0, len(data), 2))
    return s  # já é JSON puro

def encode(s, was_encoded):
    if was_encoded:
        return "CTB17" + ''.join(f'{ord(c) + 0x11:02X}' for c in s)
    return s  # devolve JSON puro

conn = sqlite3.connect(DB_PATH)
c = conn.cursor()
raw = c.execute("SELECT value FROM settings WHERE key = 'settings'").fetchone()[0]
was_encoded = raw.startswith("CTB17")
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), was_encoded),))
conn.commit()
conn.close()
print("Toggled to:", dat["additional"]["proStatus"])

@ptc-kek

ptc-kek commented Jul 4, 2026

Copy link
Copy Markdown

This actually worked. GOATed. (on M2 MacAir, MacOS Tahoe)

The only thing I changed was that I did not fully quit ColdTurkey as my OS did not allow it. Despite this, I still ran the script after I attempted to force close ColdTurkey then restarted my Mac. From here, it worked.

Best,
kek

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