PSFree icon indicating copy to clipboard operation
PSFree copied to clipboard

Free memory before running psfree

Open mrdude2478 opened this issue 3 months ago • 2 comments

In PSFree we can clear some browser memory in async function main() before starting to exploit.

First create a function to clear some memory:

async function forceGC() {
    try {
        for (let i = 0; i < 10; i++) {
            let junk = new Array(10000).fill(0);
            junk = null;
            await new Promise(resolve => setTimeout(resolve, 10)); // Give browser time to GC
        }
    }
    catch (err) {
        log("Failed to free memory");
    }
}

In the first line of async function main(), we call the function:

await forceGC();

This clears some browser memory before the exploit starts so we get less chance of out of memory error.

I tried by creating an html file to load a large jpeg before starting the exploit, this would cause a memory error when trying to run psfree, with the added function, this reduced this error quite a bit and so I thought I'd pass on the information if you want to test it. You can increase the amount you clear by altering this line - (let i = 0; i < 10; i++), increase10 to 20/30 etc...

I have mine set to 50 and that works quite well for me.

mrdude2478 avatar Sep 02 '25 07:09 mrdude2478

Another suggestion as the above which is great, increase heap grooming allocation from 0x200 to 0x400.

const num_grooms = 0x400;

Higher grooming allocation normally results in better exploit success, as it makes heap layout more deterministic

viggen66 avatar Sep 02 '25 20:09 viggen66

Great suggestions. Maybe try creating a pull request

Tamyhen avatar Oct 08 '25 07:10 Tamyhen

Simple workflow for deploying static content to GitHub Pages

name: Deploy static content to Pages

on:

Runs on pushes targeting the default branch

push: branches: ["main"]

Allows you to run this workflow manually from the Actions tab

workflow_dispatch:

Sets permissions of the GITHUB_TOKEN to allow deployment to GitHub Pages

permissions: contents: read pages: write id-token: write

Allow only one concurrent deployment, skipping runs queued between the run in-progress and latest queued.

However, do NOT cancel in-progress runs as we want to allow these production deployments to complete.

concurrency: group: "pages" cancel-in-progress: false

jobs:

Single deploy job since we're just deploying

deploy: environment: name: github-pages url: ${{ steps.deployment.outputs.page_url }} runs-on: ubuntu-latest steps: - name: Checkout uses: actions/checkout@v4 - name: Setup Pages uses: actions/configure-pages@v5 - name: Upload artifact uses: actions/upload-pages-artifact@v3 with: # Upload entire repository path: '.' - name: Deploy to GitHub Pages id: deployment uses: actions/deploy-pages@v4

felipecadorin0-netizen avatar Dec 13 '25 21:12 felipecadorin0-netizen

Simple workflow for deploying static content to GitHub Pages

name: Deploy static content to Pages

on:

Runs on pushes targeting the default branch

push: branches: ["main"]

Allows you to run this workflow manually from the Actions tab

workflow_dispatch:

Sets permissions of the GITHUB_TOKEN to allow deployment to GitHub Pages

permissions: contents: read pages: write id-token: write

Allow only one concurrent deployment, skipping runs queued between the run in-progress and latest queued.

However, do NOT cancel in-progress runs as we want to allow these production deployments to complete.

concurrency: group: "pages" cancel-in-progress: false

jobs:

Single deploy job since we're just deploying

deploy: environment: name: github-pages url: ${{ steps.deployment.outputs.page_url }} runs-on: ubuntu-latest steps: - name: Checkout uses: actions/checkout@v4 - name: Setup Pages uses: actions/configure-pages@v5 - name: Upload artifact uses: actions/upload-pages-artifact@v3 with: # Upload entire repository path: '.' - name: Deploy to GitHub Pages id: deployment uses: actions/deploy-pages@v4

:;Stop

RandQalan avatar Dec 14 '25 10:12 RandQalan