Skip to content

Commit

Permalink
Rename verbose mode, tidy command categories, regex fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
Your Name committed Sep 19, 2024
1 parent a633687 commit 4c1ee9f
Show file tree
Hide file tree
Showing 39 changed files with 293 additions and 281 deletions.
3 changes: 3 additions & 0 deletions .devcontainer/Dockerfile
Original file line number Diff line number Diff line change
@@ -1 +1,4 @@
FROM cshell AS frida-cshell
RUN apt-get update && \
apt-get install -y \
nano
6 changes: 3 additions & 3 deletions .vscode/tasks.json
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@
},
{
"type": "shell",
"command": "frida-inject-32 -s frida-cshell.js -P '{\"verbose\": true}' --interactive -f /usr/bin/target32",
"command": "frida-inject-32 -s frida-cshell.js -P '{\"debug\": true}' --interactive -f /usr/bin/target32",
"problemMatcher": [],
"label": "Debug32",
"group": {
Expand All @@ -153,7 +153,7 @@
}
{
"type": "shell",
"command": "frida-inject-64 -s frida-cshell.js -P '{\"verbose\": true}' --interactive -f /usr/bin/target64",
"command": "frida-inject-64 -s frida-cshell.js -P '{\"debug\": true}' --interactive -f /usr/bin/target64",
"problemMatcher": [],
"label": "Debug64",
"group": {
Expand Down Expand Up @@ -282,4 +282,4 @@
}
}
]
}
}
4 changes: 2 additions & 2 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
@@ -1,6 +1,6 @@
{
"name": "frida-cshell",
"version": "1.4.3",
"version": "1.4.4",
"description": "Frida's CShell",
"scripts": {
"prepare": "npm run build && npm run version && npm run package && npm run copy",
Expand Down
2 changes: 1 addition & 1 deletion src/breakpoints/bp.ts
Original file line number Diff line number Diff line change
Expand Up @@ -283,7 +283,7 @@ export class Bp {
} catch (error) {
if (error instanceof Error) {
Output.writeln(`ERROR: ${error.message}`);
Output.verboseWriteln(`${error.stack}`);
Output.debug(`${error.stack}`);
} else {
Output.writeln(`ERROR: Unknown error`);
}
Expand Down
14 changes: 7 additions & 7 deletions src/cmdlets/bp.ts → src/cmdlets/breakpoints/bp.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import { BP_LENGTH, BpType } from '../breakpoints/bp.js';
import { Bps } from '../breakpoints/bps.js';
import { CmdLet } from '../commands/cmdlet.js';
import { Input, InputInterceptLine } from '../io/input.js';
import { Output } from '../io/output.js';
import { Token } from '../io/token.js';
import { Var } from '../vars/var.js';
import { BP_LENGTH, BpType } from '../../breakpoints/bp.js';
import { Bps } from '../../breakpoints/bps.js';
import { CmdLet } from '../../commands/cmdlet.js';
import { Input, InputInterceptLine } from '../../io/input.js';
import { Output } from '../../io/output.js';
import { Token } from '../../io/token.js';
import { Var } from '../../vars/var.js';

const NUM_CHAR: string = '#';
const UNLIMITED_CHAR: string = '*';
Expand Down
12 changes: 6 additions & 6 deletions src/cmdlets/reg.ts → src/cmdlets/breakpoints/reg.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import { CmdLet } from '../commands/cmdlet.js';
import { Output } from '../io/output.js';
import { Vars } from '../vars/vars.js';
import { Token } from '../io/token.js';
import { Var } from '../vars/var.js';
import { Regs } from '../breakpoints/regs.js';
import { CmdLet } from '../../commands/cmdlet.js';
import { Output } from '../../io/output.js';
import { Vars } from '../../vars/vars.js';
import { Token } from '../../io/token.js';
import { Var } from '../../vars/var.js';
import { Regs } from '../../breakpoints/regs.js';

const USAGE: string = `Usage: R
R - show the values of all registers
Expand Down
12 changes: 6 additions & 6 deletions src/cmdlets/assembly.ts → src/cmdlets/data/assembly.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import { CmdLet } from '../commands/cmdlet.js';
import { Output } from '../io/output.js';
import { Format } from '../misc/format.js';
import { Token } from '../io/token.js';
import { Var } from '../vars/var.js';
import { Mem } from '../memory/mem.js';
import { CmdLet } from '../../commands/cmdlet.js';
import { Output } from '../../io/output.js';
import { Format } from '../../misc/format.js';
import { Token } from '../../io/token.js';
import { Var } from '../../vars/var.js';
import { Mem } from '../../memory/mem.js';

const DEFAULT_LENGTH: number = 10;
const USAGE: string = `Usage: l
Expand Down
12 changes: 6 additions & 6 deletions src/cmdlets/copy.ts → src/cmdlets/data/copy.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import { CmdLet } from '../commands/cmdlet.js';
import { Output } from '../io/output.js';
import { Format } from '../misc/format.js';
import { Token } from '../io/token.js';
import { Var } from '../vars/var.js';
import { Mem } from '../memory/mem.js';
import { CmdLet } from '../../commands/cmdlet.js';
import { Output } from '../../io/output.js';
import { Format } from '../../misc/format.js';
import { Token } from '../../io/token.js';
import { Var } from '../../vars/var.js';
import { Mem } from '../../memory/mem.js';

const USAGE: string = `Usage: cp
Expand Down
12 changes: 6 additions & 6 deletions src/cmdlets/dump.ts → src/cmdlets/data/dump.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import { CmdLet } from '../commands/cmdlet.js';
import { Output } from '../io/output.js';
import { Format } from '../misc/format.js';
import { Token } from '../io/token.js';
import { Var } from '../vars/var.js';
import { Mem } from '../memory/mem.js';
import { CmdLet } from '../../commands/cmdlet.js';
import { Output } from '../../io/output.js';
import { Format } from '../../misc/format.js';
import { Token } from '../../io/token.js';
import { Var } from '../../vars/var.js';
import { Mem } from '../../memory/mem.js';

const ROW_WIDTH: number = 16;
const DEFAULT_COUNT: number = 32;
Expand Down
12 changes: 6 additions & 6 deletions src/cmdlets/read.ts → src/cmdlets/data/read.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import { CmdLet } from '../commands/cmdlet.js';
import { Output } from '../io/output.js';
import { Format } from '../misc/format.js';
import { Token } from '../io/token.js';
import { Var } from '../vars/var.js';
import { Mem } from '../memory/mem.js';
import { CmdLet } from '../../commands/cmdlet.js';
import { Output } from '../../io/output.js';
import { Format } from '../../misc/format.js';
import { Token } from '../../io/token.js';
import { Var } from '../../vars/var.js';
import { Mem } from '../../memory/mem.js';

export class ReadCmdLet extends CmdLet {
name = 'r';
Expand Down
12 changes: 6 additions & 6 deletions src/cmdlets/string.ts → src/cmdlets/data/string.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import { CmdLet } from '../commands/cmdlet.js';
import { Output } from '../io/output.js';
import { Format } from '../misc/format.js';
import { Token } from '../io/token.js';
import { Var } from '../vars/var.js';
import { Mem } from '../memory/mem.js';
import { CmdLet } from '../../commands/cmdlet.js';
import { Output } from '../../io/output.js';
import { Format } from '../../misc/format.js';
import { Token } from '../../io/token.js';
import { Var } from '../../vars/var.js';
import { Mem } from '../../memory/mem.js';

const MAX_STRING_LENGTH: number = 1024;
const USAGE: string = `Usage: ds
Expand Down
12 changes: 6 additions & 6 deletions src/cmdlets/write.ts → src/cmdlets/data/write.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import { CmdLet } from '../commands/cmdlet.js';
import { Output } from '../io/output.js';
import { Format } from '../misc/format.js';
import { Token } from '../io/token.js';
import { Var } from '../vars/var.js';
import { Mem } from '../memory/mem.js';
import { CmdLet } from '../../commands/cmdlet.js';
import { Output } from '../../io/output.js';
import { Format } from '../../misc/format.js';
import { Token } from '../../io/token.js';
import { Var } from '../../vars/var.js';
import { Mem } from '../../memory/mem.js';

export class WriteCmdLet extends CmdLet {
name = 'w';
Expand Down
30 changes: 30 additions & 0 deletions src/cmdlets/development/debug.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
import { CmdLet } from '../../commands/cmdlet.js';
import { Output } from '../../io/output.js';
import { Token } from '../../io/token.js';
import { Var } from '../../vars/var.js';

const USAGE: string = `Usage: debug
debug - toggle debug mode`;

export class DebugCmdLet extends CmdLet {
name = 'debug';
category = 'development';
help = 'toggle debug mode';

public runSync(_tokens: Token[]): Var {
const debug = !Output.getDebugging();
if (debug) {
Output.writeln(`debug mode ${Output.green('enabled')}`);
} else {
Output.writeln(`debug mode ${Output.red('disabled')}`);
}
Output.setDebugging(debug);

return Var.ZERO;
}

public usage(): Var {
Output.writeln(USAGE);
return Var.ZERO;
}
}
92 changes: 46 additions & 46 deletions src/cmdlets/js.ts → src/cmdlets/development/js.ts
Original file line number Diff line number Diff line change
@@ -1,40 +1,40 @@
import { Bp } from '../breakpoints/bp.js';
import { Bps } from '../breakpoints/bps.js';
import { MemoryBps } from '../breakpoints/memory.js';
import { Regs } from '../breakpoints/regs.js';
import { CmdLet } from '../commands/cmdlet.js';
import { CmdLets } from '../commands/cmdlets.js';
import { Command } from '../commands/command.js';
import { CharCode, Vt } from '../io/char.js';
import { Input } from '../io/input.js';
import { Output } from '../io/output.js';
import { Parser } from '../io/parser.js';
import { Token } from '../io/token.js';
import { Mem } from '../memory/mem.js';
import { Overlay } from '../memory/overlay.js';
import { Base64 } from '../misc/base64.js';
import { Format } from '../misc/format.js';
import { Numeric } from '../misc/numeric.js';
import { History } from '../terminal/history.js';
import { Line } from '../terminal/line.js';
import { Var } from '../vars/var.js';
import { Vars } from '../vars/vars.js';
import { AssemblyCmdLet } from './assembly.js';
import { Bp } from '../../breakpoints/bp.js';
import { Bps } from '../../breakpoints/bps.js';
import { MemoryBps } from '../../breakpoints/memory.js';
import { Regs } from '../../breakpoints/regs.js';
import { CmdLet } from '../../commands/cmdlet.js';
import { CmdLets } from '../../commands/cmdlets.js';
import { Command } from '../../commands/command.js';
import { CharCode, Vt } from '../../io/char.js';
import { Input } from '../../io/input.js';
import { Output } from '../../io/output.js';
import { Parser } from '../../io/parser.js';
import { Token } from '../../io/token.js';
import { Mem } from '../../memory/mem.js';
import { Overlay } from '../../memory/overlay.js';
import { Base64 } from '../../misc/base64.js';
import { Format } from '../../misc/format.js';
import { Numeric } from '../../misc/numeric.js';
import { History } from '../../terminal/history.js';
import { Line } from '../../terminal/line.js';
import { Var } from '../../vars/var.js';
import { Vars } from '../../vars/vars.js';
import { AssemblyCmdLet } from '../data/assembly.js';
import {
FunctionEntryBpCmdLet,
FunctionExitBpCmdLet,
InsnBpCmdLet,
ReadBpCmdLet,
WriteBpCmdLet,
} from './bp.js';
import { BtCmdLet } from './bt.js';
import { CopyCmdLet } from './copy.js';
import { DumpCmdLet } from './dump.js';
import { ExitCmdLet } from './exit.js';
import { FdCmdLet } from './fd.js';
import { HelpCmdLet } from './help.js';
import { HistoryCmdLet } from './history.js';
import { LdCmdLet } from './ld.js';
} from '../breakpoints/bp.js';
import { BtCmdLet } from '../thread/bt.js';
import { CopyCmdLet } from '../data/copy.js';
import { DumpCmdLet } from '../data/dump.js';
import { ExitCmdLet } from '../misc/exit.js';
import { FdCmdLet } from '../files/fd.js';
import { HelpCmdLet } from '../misc/help.js';
import { HistoryCmdLet } from '../misc/history.js';
import { LdCmdLet } from '../modules/ld.js';
import {
AddCmdLet,
AndCmdLet,
Expand All @@ -46,27 +46,27 @@ import {
ShrCmdLet,
SubCmdLet,
XorCmdLet,
} from './math.js';
import { ModCmdLet } from './mod.js';
import { ReadCmdLet } from './read.js';
import { RegCmdLet } from './reg.js';
import { SymCmdLet } from './sym.js';
import { ThreadCmdLet } from './thread.js';
import { VarCmdLet } from './var.js';
import { VmCmdLet } from './vm.js';
import { WriteCmdLet } from './write.js';
import { GrepCmdLet } from './grep.js';
import { CatCmdLet } from './cat.js';
import { LogCmdLet } from './log.js';
} from '../math/math.js';
import { ModCmdLet } from '../modules/mod.js';
import { ReadCmdLet } from '../data/read.js';
import { RegCmdLet } from '../breakpoints/reg.js';
import { SymCmdLet } from '../memory/sym.js';
import { ThreadCmdLet } from '../thread/thread.js';
import { VarCmdLet } from '../misc/var.js';
import { VmCmdLet } from '../memory/vm.js';
import { WriteCmdLet } from '../data/write.js';
import { GrepCmdLet } from '../misc/grep.js';
import { CatCmdLet } from '../files/cat.js';
import { LogCmdLet } from '../misc/log.js';

const USAGE: string = `Usage: js
js path - load JS script
path the absolute path of the script to load (note that paths with spaces must be quoted)`;
js path - load commandlet JS script
path the absolute path of the commandlet script to load (note that paths with spaces must be quoted)`;

export class JsCmdLet extends CmdLet {
name = 'js';
category = 'misc';
category = 'development';
help = 'load script';

public runSync(tokens: Token[]): Var {
Expand Down
10 changes: 5 additions & 5 deletions src/cmdlets/cat.ts → src/cmdlets/files/cat.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { CmdLet } from '../commands/cmdlet.js';
import { Output } from '../io/output.js';
import { Token } from '../io/token.js';
import { Var } from '../vars/var.js';
import { CmdLet } from '../../commands/cmdlet.js';
import { Output } from '../../io/output.js';
import { Token } from '../../io/token.js';
import { Var } from '../../vars/var.js';

const USAGE: string = `Usage: cat
Expand All @@ -10,7 +10,7 @@ cat file - dump file

export class CatCmdLet extends CmdLet {
name = 'cat';
category = 'misc';
category = 'files';
help = 'dump a file';

public runSync(tokens: Token[]): Var {
Expand Down
10 changes: 5 additions & 5 deletions src/cmdlets/fd.ts → src/cmdlets/files/fd.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { CmdLet } from '../commands/cmdlet.js';
import { Output } from '../io/output.js';
import { Token } from '../io/token.js';
import { Var } from '../vars/var.js';
import { CmdLet } from '../../commands/cmdlet.js';
import { Output } from '../../io/output.js';
import { Token } from '../../io/token.js';
import { Var } from '../../vars/var.js';

enum DtType {
DT_UNKNOWN = 0 /* The file type is unknown. */,
Expand All @@ -27,7 +27,7 @@ type Fds = {

export class FdCmdLet extends CmdLet {
name = 'fd';
category = 'misc';
category = 'files';
help = 'display file descriptors';

private static readonly PATH_MAX: number = 4096;
Expand Down
Loading

0 comments on commit 4c1ee9f

Please sign in to comment.