Skip to content

Commit

Permalink
better descriptions
Browse files Browse the repository at this point in the history
  • Loading branch information
mariotaku committed Jun 18, 2024
1 parent 979f805 commit dfee2c2
Show file tree
Hide file tree
Showing 3 changed files with 45 additions and 17 deletions.
8 changes: 4 additions & 4 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
"dependencies": {
"@fontsource/orbitron": "^5.0.19",
"@popperjs/core": "^2.11.8",
"@webosbrew/caniroot": "^1.0.2",
"@webosbrew/caniroot": "^1.0.3",
"bootstrap": "^5.3.3",
"bootstrap-icons": "^1.11.3",
"gsap": "^3.12.5",
Expand Down
52 changes: 40 additions & 12 deletions src/views/can-i-root/app.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,25 +23,25 @@ interface SearchTerm {

function parseSearchTerm(q?: string): SearchTerm | undefined {
if (!q) return undefined;
const model = q.match(/[A-Z0-9-]{4,12}(?:\.[A-Z0-9]{2,4})?/)?.[0];
const model = q.match(/[A-Z0-9-]{4,12}(?:\.[A-Z0-9]{2,4})?/)?.[0]?.toUpperCase();
const firmware = q.match(/\d{2}\.\d{2}\.\d{2}/)?.[0];
return {q, model, firmware};
}

interface ExploitMethod {
name: string;
key: keyof DeviceExploitAvailabilities;
url:string;
expert?: boolean;
}

class App extends Component<AppProps, AppState> {

readonly exploits: ExploitMethod[] = [
{name: 'DejaVuln', key: 'dejavuln'},
{name: 'crashd', key: 'crashd'},
{name: 'WTA', key: 'wta'},
{name: 'rootmytv', key: 'rootmytv'},
{name: 'NVM', key: 'nvm', expert: true},
{name: 'DejaVuln', key: 'dejavuln', url: 'https://github.com/throwaway96/dejavuln-autoroot'},
{name: 'crashd', key: 'crashd', url: 'https://gist.github.com/throwaway96/e811b0f7cc2a705a5a476a8dfa45e09f'},
{name: 'WTA', key: 'wta', url: 'https://gist.github.com/throwaway96/b171240ef59d7f5fd6fb48fc6dfd2941'},
{name: 'RootMy.TV', key: 'rootmytv', url: 'https://rootmy.tv/'},
];

constructor(props: AppProps) {
Expand All @@ -60,6 +60,11 @@ class App extends Component<AppProps, AppState> {
let model = term && DeviceModel.findModel(term.model ?? '');
let availability = model && DeviceExploitAvailabilities.byOTAID(model.otaId);
this.setState({term, model, availability});
const url = new URL(location.href);
if (url.searchParams) {
url.searchParams.set('q', q);
history.pushState(null, '', url);
}
}, 300);

render(_props: RenderableProps<AppProps>, state: Readonly<AppState>) {
Expand All @@ -70,7 +75,7 @@ class App extends Component<AppProps, AppState> {
onInput=${(e: TargetedInputEvent<HTMLInputElement>) => this.searchChanged(e.currentTarget.value)}/>
${state.term && (state.model ?
html`
<div class="alert alert-success mt-3" role="alert">Found otaId <code>${state.model.otaId}</code>,
<div class="alert alert-success mt-3" role="alert">Found otaId <code>${state.model.otaId}</code>,
broadcast <code>${state.model.broadcast}</code>, region <code>${state.model.region}</code>
</div>
<hr/>` :
Expand All @@ -85,16 +90,39 @@ class App extends Component<AppProps, AppState> {
const patched = (avail?.patched && firmware && firmware >= avail.patched.version) || false;
return avail && html`
<div class=${`card p-3 mt-3 ${patched ? 'bg-danger-subtle' : 'bg-success-subtle'}`}>
<h3>${exploit.name}</h3>
<div><i class="bi bi-hand-thumbs-up-fill"/> Latest known working firmware: ${avail.latest?.version}
</div>
<h3><i class="bi ${patched ? 'bi-sign-stop-fill' : 'bi-hand-thumbs-up-fill'}"/> ${exploit.name}</h3>
${avail.latest && html`
<div>
<i class="bi bi-info-circle-fill me-2"/>Latest known working firmware: <b>${avail.latest?.version}
</b>
</div>
`}
${avail.patched && html`
<div><i class="bi bi-bandaid-fill"/> Patched in: ${avail.patched?.version}
${state.term?.firmware && html` (you have ${state.term.firmware})`}
<div><i class="bi bi-bandaid-fill me-2"/>Patched in: <b>${avail.patched?.version}</b>
${state.term?.firmware && html` (you have <b>${state.term.firmware}</b>)`}
</div>
`}
${exploit.expert && html`
<div>
<i class="bi bi-exclamation-triangle-fill me-2"/>Requires expert knowledge.
</div>
`}
<a class="stretched-link" href="${exploit.url}" target="_blank">Read manual</a>
</div>`;
})}
${state.availability?.nvm && html`
<div class="card p-3 mt-3 bg-info-subtle">
<h3><i class="bi bi-cpu-fill me-2"></i>NVM</h3>
<div>
Alternatively, you can try reprogramming the NVRAM chip to enable root access. <br/>
<i class="bi bi-exclamation-triangle-fill me-2"/>This method requires expert knowledge. <a
class="stretched-link" href="https://gist.github.com/throwaway96/827ff726981cc2cbc46a22a2ad7337a1"
target="_blank">Read manual</a>
</div>
</div>
`
}
</div>
`;
}
Expand Down

0 comments on commit dfee2c2

Please sign in to comment.