Skip to content

Commit

Permalink
+Fermion-v17
Browse files Browse the repository at this point in the history
  • Loading branch information
FuzzySecurity committed Sep 7, 2021
1 parent c4379f3 commit 348dad3
Show file tree
Hide file tree
Showing 9 changed files with 325 additions and 68 deletions.
9 changes: 8 additions & 1 deletion CHANGELOG.txt
Original file line number Diff line number Diff line change
Expand Up @@ -93,4 +93,11 @@
* Disable contextIsolation for window communications
* Bugfix for https://github.com/FuzzySecurity/Fermion/issues/12
* Four new themes: Amy, Oceanic Next, Tomorrow Night Blue, Vibrant Ink
* More minor UI colour changes. I'm still thinking of a full re-design for v2.
* More minor UI colour changes. I'm still thinking of a full re-design for v2.

-= Fermion v1.7 =-

* Pre-built release updated to Frida v15.1.1
* Updated language bindings
* Better process information User/PID/PPID. On devices where "parameters.icons" have a type of RGBA they are drawn to a canvas inline. In my testing Ubuntu did not have icons in which case they are not drawn. The release notes for v15 say that some devices like IOS/Android now return a PNG byte array, currently those are not drawn either, PR's welcome.
* The main UI now has a button which retrieves Device information as per the new specs in the v15 release notes.
Binary file modified Fermion/assets/img/version.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
249 changes: 199 additions & 50 deletions Fermion/assets/lang/frida.d.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
// Type definitions for non-npm package frida-gum 17.0
// Type definitions for non-npm package frida-gum 17.1
// Project: https://github.com/frida/frida
// Definitions by: Ole André Vadla Ravnås <https://github.com/oleavr>
// Francesco Tamagni <https://github.com/mrmacete>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
// Minimum TypeScript Version: 3.5
// Minimum TypeScript Version: 4.1

/**
* Returns a hexdump of the provided ArrayBuffer or NativePointerValue target.
Expand Down Expand Up @@ -1604,46 +1604,81 @@
declare const NativeFunction: NativeFunctionConstructor;

interface NativeFunctionConstructor {
new(address: NativePointerValue, retType: NativeType, argTypes: NativeType[], abiOrOptions?: NativeABI | NativeFunctionOptions): NativeFunction;
readonly prototype: NativeFunction;
new <RetType extends NativeFunctionReturnType, ArgTypes extends NativeFunctionArgumentType[] | []>(
address: NativePointerValue,
retType: RetType,
argTypes: ArgTypes,
abiOrOptions?: NativeABI | NativeFunctionOptions,
): NativeFunction<
GetNativeFunctionReturnValue<RetType>,
ResolveVariadic<Extract<GetNativeFunctionArgumentValue<ArgTypes>, unknown[]>>
>;
readonly prototype: NativeFunction<void, []>;
}

interface NativeFunction extends NativePointer {
(...args: NativeArgumentValue[]): NativeReturnValue;
apply(thisArg: NativePointerValue | null | undefined, args: NativeArgumentValue[]): NativeReturnValue;
call(thisArg?: NativePointerValue | null, ...args: NativeArgumentValue[]): NativeReturnValue;
interface NativeFunction<RetType extends NativeFunctionReturnValue, ArgTypes extends NativeFunctionArgumentValue[] | []>
extends NativePointer {
(...args: ArgTypes): RetType;
apply(thisArg: NativePointerValue | null | undefined, args: ArgTypes): RetType;
call(thisArg?: NativePointerValue | null, ...args: ArgTypes): RetType;
}

declare const SystemFunction: SystemFunctionConstructor;

interface SystemFunctionConstructor {
new(address: NativePointerValue, retType: NativeType, argTypes: NativeType[], abiOrOptions?: NativeABI | NativeFunctionOptions): SystemFunction;
readonly prototype: SystemFunction;
}

interface SystemFunction extends NativePointer {
(...args: NativeArgumentValue[]): SystemFunctionResult;
apply(thisArg: NativePointerValue | null | undefined, args: NativeArgumentValue[]): SystemFunctionResult;
call(thisArg?: NativePointerValue | null, ...args: NativeArgumentValue[]): SystemFunctionResult;
}

type SystemFunctionResult = WindowsSystemFunctionResult | UnixSystemFunctionResult;
new <RetType extends NativeFunctionReturnType, ArgTypes extends NativeFunctionArgumentType[] | []>(
address: NativePointerValue,
retType: RetType,
argTypes: ArgTypes,
abiOrOptions?: NativeABI | NativeFunctionOptions,
): SystemFunction<
GetNativeFunctionReturnValue<RetType>,
ResolveVariadic<Extract<GetNativeFunctionArgumentValue<ArgTypes>, unknown[]>>
>;
readonly prototype: SystemFunction<void, []>;
}

interface SystemFunction<RetType extends NativeFunctionReturnValue, ArgTypes extends NativeFunctionArgumentValue[] | []>
extends NativePointer {
(...args: ArgTypes): SystemFunctionResult<RetType>;
apply(thisArg: NativePointerValue | null | undefined, args: ArgTypes): SystemFunctionResult<RetType>;
call(thisArg?: NativePointerValue | null, ...args: ArgTypes): SystemFunctionResult<RetType>;
}

type SystemFunctionResult<Value extends NativeFunctionReturnValue> =
| WindowsSystemFunctionResult<Value>
| UnixSystemFunctionResult<Value>
;

interface WindowsSystemFunctionResult {
value: NativeReturnValue;
interface WindowsSystemFunctionResult<Value extends NativeFunctionReturnValue> {
value: Value;
lastError: number;
}

interface UnixSystemFunctionResult {
value: NativeReturnValue;
interface UnixSystemFunctionResult<Value extends NativeFunctionReturnValue> {
value: Value;
errno: number;
}

declare class NativeCallback extends NativePointer {
constructor(func: NativeCallbackImplementation, retType: NativeType, argTypes: NativeType[], abi?: NativeABI);
declare class NativeCallback<
RetType extends NativeCallbackReturnType,
ArgTypes extends NativeCallbackArgumentType[] | [],
> extends NativePointer {
constructor(
func: NativeCallbackImplementation<
GetNativeCallbackReturnValue<RetType>,
Extract<GetNativeCallbackArgumentValue<ArgTypes>, unknown[]>
>,
retType: RetType,
argTypes: ArgTypes,
abi?: NativeABI,
);
}

type NativeCallbackImplementation = (this: CallbackContext | InvocationContext, ...params: any[]) => any;
type NativeCallbackImplementation<
RetType extends NativeCallbackReturnValue,
ArgTypes extends NativeCallbackArgumentValue[] | [],
> = (this: CallbackContext | InvocationContext, ...args: ArgTypes) => RetType;

interface CallbackContext {
/**
Expand All @@ -1659,11 +1694,125 @@
context: CpuContext;
}

type NativeArgumentValue = NativePointerValue | UInt64 | Int64 | number | boolean | any[];

type NativeReturnValue = NativePointer | UInt64 | Int64 | number | boolean | any[];

type NativeType = string | any[];
type Variadic = "...";

type ResolveVariadic<List extends any[]> = List extends [Variadic, ...infer Tail]
? [...Array<Tail[0]>]
: List extends [infer Head, ...infer Tail]
? [Head, ...ResolveVariadic<Tail>]
: [];

type RecursiveValuesOf<T> = T[keyof T] | Array<RecursiveValuesOf<T>>;

type RecursiveKeysOf<T> = keyof T | Array<RecursiveKeysOf<T>> | [];

type GetValue<Map, Value, Type, T extends Type> = Type[] extends T
? Value
: T extends keyof Map
? Map[T]
: { [P in keyof T]: T[P] extends Type ? GetValue<Map, Value, Type, T[P]> : never };

// tslint:disable-next-line:interface-over-type-literal
type BaseNativeTypeMap = {
int: number;
uint: number;
long: number;
ulong: number;
char: number;
uchar: number;
float: number;
double: number;
int8: number;
uint8: number;
int16: number;
uint16: number;
int32: number;
uint32: number;
bool: number;
};

type NativeFunctionArgumentTypeMap = BaseNativeTypeMap & {
void: undefined;
pointer: NativePointerValue;
size_t: number | UInt64;
ssize_t: number | Int64;
int64: number | Int64;
uint64: number | UInt64;
"...": Variadic;
};

type NativeFunctionArgumentValue = RecursiveValuesOf<NativeFunctionArgumentTypeMap>;

type NativeFunctionArgumentType = RecursiveKeysOf<NativeFunctionArgumentTypeMap>;

type GetNativeFunctionArgumentValue<T extends NativeFunctionArgumentType> = GetValue<
NativeFunctionArgumentTypeMap,
NativeFunctionArgumentValue,
NativeFunctionArgumentType,
T
>;

type NativeFunctionReturnTypeMap = BaseNativeTypeMap & {
// tslint:disable-next-line:void-return
void: void;
pointer: NativePointer;
size_t: UInt64;
ssize_t: Int64;
int64: Int64;
uint64: UInt64;
};

type NativeFunctionReturnValue = RecursiveValuesOf<NativeFunctionReturnTypeMap>;

type NativeFunctionReturnType = RecursiveKeysOf<NativeFunctionReturnTypeMap>;

type GetNativeFunctionReturnValue<T extends NativeFunctionReturnType> = GetValue<
NativeFunctionReturnTypeMap,
NativeFunctionReturnValue,
NativeFunctionReturnType,
T
>;

type NativeCallbackArgumentTypeMap = BaseNativeTypeMap & {
void: undefined;
pointer: NativePointer;
size_t: UInt64;
ssize_t: Int64;
int64: Int64;
uint64: UInt64;
};

type NativeCallbackArgumentValue = RecursiveValuesOf<NativeCallbackArgumentTypeMap>;

type NativeCallbackArgumentType = RecursiveKeysOf<NativeCallbackArgumentTypeMap>;

type GetNativeCallbackArgumentValue<T extends NativeCallbackArgumentType> = GetValue<
NativeCallbackArgumentTypeMap,
NativeCallbackArgumentValue,
NativeCallbackArgumentType,
T
>;

type NativeCallbackReturnTypeMap = BaseNativeTypeMap & {
// tslint:disable-next-line:void-return
void: void;
pointer: NativePointerValue;
size_t: number | UInt64;
ssize_t: number | Int64;
int64: number | Int64;
uint64: number | UInt64;
};

type NativeCallbackReturnValue = RecursiveValuesOf<NativeCallbackReturnTypeMap>;

type NativeCallbackReturnType = RecursiveKeysOf<NativeCallbackReturnTypeMap>;

type GetNativeCallbackReturnValue<T extends NativeCallbackReturnType> = GetValue<
NativeCallbackReturnTypeMap,
NativeCallbackReturnValue,
NativeCallbackReturnType,
T
>;

type NativeABI =
| "default"
Expand Down Expand Up @@ -3065,27 +3214,27 @@
* through the constructor's second argument.
*/
declare class CModule {
/**
* Creates a new C module from the provided `code`.
*
* @param code C source code to compile, or a precompiled shared library.
* @param symbols Symbols to expose to the C module. Declare them as `extern`.
* This may for example be one or more memory blocks allocated using
* `Memory.alloc()`, and/or `NativeCallback` values for receiving
* callbacks from the C module.
* @param options Options for customizing the construction.
*/
constructor(code: string | ArrayBuffer, symbols?: CSymbols, options?: CModuleOptions);
/**
* Creates a new C module from the provided `code`.
*
* @param code C source code to compile, or a precompiled shared library.
* @param symbols Symbols to expose to the C module. Declare them as `extern`.
* This may for example be one or more memory blocks allocated using
* `Memory.alloc()`, and/or `NativeCallback` values for receiving
* callbacks from the C module.
* @param options Options for customizing the construction.
*/
constructor(code: string | ArrayBuffer, symbols?: CSymbols, options?: CModuleOptions);

/**
* Eagerly unmaps the module from memory. Useful for short-lived modules
* when waiting for a future garbage collection isn't desirable.
*/
dispose(): void;
/**
* Eagerly unmaps the module from memory. Useful for short-lived modules
* when waiting for a future garbage collection isn't desirable.
*/
dispose(): void;

readonly [name: string]: any;
readonly [name: string]: any;

static builtins: CModuleBuiltins;
static builtins: CModuleBuiltins;
}

interface CModuleOptions {
Expand Down Expand Up @@ -3918,7 +4067,7 @@
* @param method Method to implement.
* @param fn Implementation.
*/
function implement(method: ObjectMethod, fn: AnyFunction): NativeCallback;
function implement(method: ObjectMethod, fn: AnyFunction): NativeCallback<any, any>;

/**
* Creates a new class designed to act as a proxy for a target object.
Expand Down
2 changes: 1 addition & 1 deletion Fermion/core.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ function createWindow() {
bWin = new BrowserWindow({
contextIsolation: false,
width: 1000,
height: 900,
height: 930,
frame: false,
show: false,
backgroundColor: '#464646',
Expand Down
4 changes: 2 additions & 2 deletions Fermion/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "fermion",
"version": "1.6.0",
"version": "1.7.0",
"description": "Fermion is a stand-alone Frida electron tool.",
"main": "core.js",
"scripts": {
Expand All @@ -11,7 +11,7 @@
"license": "BSD-3-Clause",
"dependencies": {
"electron": "13.1.6",
"frida": "15.0.2",
"frida": "15.1.1",
"jquery": "^3.4.1",
"monaco-editor": "0.17.0",
"mutex-promise": "0.1.0"
Expand Down
11 changes: 7 additions & 4 deletions Fermion/src/frida.html
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,10 @@
</div>
<ul class="list-unstyled CTAs">
<li>
<button type="button" id="setDevice" class="btn btn-goon btn-sm btn-block btn-space">Configure</button>
<button type="button" id="getDeviceDetail" class="btn btn-secondary btn-sm btn-block btn-space">Device Info</button>
</li>
<li>
<button type="button" id="setDevice" class="btn btn-goon btn-sm btn-block btn-space">Configure</button>
</li>
</ul><br>
<div class="form-group mx-sm-3 mb-2">
Expand Down Expand Up @@ -218,7 +221,7 @@
var editor = monaco.editor.create(document.getElementById('container'), {
value: [
'//-------------------------------------------//',
'// Fermion v1.6 //',
'// Fermion v1.7 //',
'// ~b33f //',
'//-------------------------------------------//',
'',
Expand Down Expand Up @@ -264,8 +267,8 @@
<script type="text/javascript">

// Print release firda version to textarea
appendFridaLog("[+] Fermion v1.6 -> Frida v15.0.2");
appendFridaLog(" |_ https://github.com/frida/frida/releases/tag/15.0.2");
appendFridaLog("[+] Fermion v1.7 -> Frida v15.1.1");
appendFridaLog(" |_ https://github.com/frida/frida/releases/tag/15.1.1");

$(document).ready(function () {
$('#sidebarCollapse').on('click', function () {
Expand Down
Loading

0 comments on commit 348dad3

Please sign in to comment.