Init
This commit is contained in:
commit
552f4096ef
16
.editorconfig
Normal file
16
.editorconfig
Normal file
@ -0,0 +1,16 @@
|
||||
# Editor configuration, see https://editorconfig.org
|
||||
root = true
|
||||
|
||||
[*]
|
||||
charset = utf-8
|
||||
indent_style = space
|
||||
indent_size = 2
|
||||
insert_final_newline = true
|
||||
trim_trailing_whitespace = true
|
||||
|
||||
[*.ts]
|
||||
quote_type = single
|
||||
|
||||
[*.md]
|
||||
max_line_length = off
|
||||
trim_trailing_whitespace = false
|
11
.fleet/run.json
Normal file
11
.fleet/run.json
Normal file
@ -0,0 +1,11 @@
|
||||
{
|
||||
"configurations": [
|
||||
{
|
||||
"type": "command",
|
||||
"name": "Run",
|
||||
"program": "npm.exe",
|
||||
"args": ["run", "start"]
|
||||
},
|
||||
|
||||
]
|
||||
}
|
42
.gitignore
vendored
Normal file
42
.gitignore
vendored
Normal file
@ -0,0 +1,42 @@
|
||||
# See http://help.github.com/ignore-files/ for more about ignoring files.
|
||||
|
||||
# Compiled output
|
||||
/dist
|
||||
/tmp
|
||||
/out-tsc
|
||||
/bazel-out
|
||||
|
||||
# Node
|
||||
/node_modules
|
||||
npm-debug.log
|
||||
yarn-error.log
|
||||
|
||||
# IDEs and editors
|
||||
.idea/
|
||||
.project
|
||||
.classpath
|
||||
.c9/
|
||||
*.launch
|
||||
.settings/
|
||||
*.sublime-workspace
|
||||
|
||||
# Visual Studio Code
|
||||
.vscode/*
|
||||
!.vscode/settings.json
|
||||
!.vscode/tasks.json
|
||||
!.vscode/launch.json
|
||||
!.vscode/extensions.json
|
||||
.history/*
|
||||
|
||||
# Miscellaneous
|
||||
/.angular/cache
|
||||
.sass-cache/
|
||||
/connect.lock
|
||||
/coverage
|
||||
/libpeerconnection.log
|
||||
testem.log
|
||||
/typings
|
||||
|
||||
# System files
|
||||
.DS_Store
|
||||
Thumbs.db
|
4
.vscode/extensions.json
vendored
Normal file
4
.vscode/extensions.json
vendored
Normal file
@ -0,0 +1,4 @@
|
||||
{
|
||||
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=827846
|
||||
"recommendations": ["angular.ng-template"]
|
||||
}
|
20
.vscode/launch.json
vendored
Normal file
20
.vscode/launch.json
vendored
Normal file
@ -0,0 +1,20 @@
|
||||
{
|
||||
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
|
||||
"version": "0.2.0",
|
||||
"configurations": [
|
||||
{
|
||||
"name": "ng serve",
|
||||
"type": "pwa-chrome",
|
||||
"request": "launch",
|
||||
"preLaunchTask": "npm: start",
|
||||
"url": "http://localhost:4200/"
|
||||
},
|
||||
{
|
||||
"name": "ng test",
|
||||
"type": "chrome",
|
||||
"request": "launch",
|
||||
"preLaunchTask": "npm: test",
|
||||
"url": "http://localhost:9876/debug.html"
|
||||
}
|
||||
]
|
||||
}
|
42
.vscode/tasks.json
vendored
Normal file
42
.vscode/tasks.json
vendored
Normal file
@ -0,0 +1,42 @@
|
||||
{
|
||||
// For more information, visit: https://go.microsoft.com/fwlink/?LinkId=733558
|
||||
"version": "2.0.0",
|
||||
"tasks": [
|
||||
{
|
||||
"type": "npm",
|
||||
"script": "start",
|
||||
"isBackground": true,
|
||||
"problemMatcher": {
|
||||
"owner": "typescript",
|
||||
"pattern": "$tsc",
|
||||
"background": {
|
||||
"activeOnStart": true,
|
||||
"beginsPattern": {
|
||||
"regexp": "(.*?)"
|
||||
},
|
||||
"endsPattern": {
|
||||
"regexp": "bundle generation complete"
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "npm",
|
||||
"script": "test",
|
||||
"isBackground": true,
|
||||
"problemMatcher": {
|
||||
"owner": "typescript",
|
||||
"pattern": "$tsc",
|
||||
"background": {
|
||||
"activeOnStart": true,
|
||||
"beginsPattern": {
|
||||
"regexp": "(.*?)"
|
||||
},
|
||||
"endsPattern": {
|
||||
"regexp": "bundle generation complete"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
27
README.md
Normal file
27
README.md
Normal file
@ -0,0 +1,27 @@
|
||||
# Hacknet
|
||||
|
||||
This project was generated with [Angular CLI](https://github.com/angular/angular-cli) version 15.0.2.
|
||||
|
||||
## Development server
|
||||
|
||||
Run `ng serve` for a dev server. Navigate to `http://localhost:4200/`. The application will automatically reload if you change any of the source files.
|
||||
|
||||
## Code scaffolding
|
||||
|
||||
Run `ng generate component component-name` to generate a new component. You can also use `ng generate directive|pipe|service|class|guard|interface|enum|module`.
|
||||
|
||||
## Build
|
||||
|
||||
Run `ng build` to build the project. The build artifacts will be stored in the `dist/` directory.
|
||||
|
||||
## Running unit tests
|
||||
|
||||
Run `ng test` to execute the unit tests via [Karma](https://karma-runner.github.io).
|
||||
|
||||
## Running end-to-end tests
|
||||
|
||||
Run `ng e2e` to execute the end-to-end tests via a platform of your choice. To use this command, you need to first add a package that implements end-to-end testing capabilities.
|
||||
|
||||
## Further help
|
||||
|
||||
To get more help on the Angular CLI use `ng help` or go check out the [Angular CLI Overview and Command Reference](https://angular.io/cli) page.
|
107
angular.json
Normal file
107
angular.json
Normal file
@ -0,0 +1,107 @@
|
||||
{
|
||||
"$schema": "./node_modules/@angular/cli/lib/config/schema.json",
|
||||
"version": 1,
|
||||
"newProjectRoot": "projects",
|
||||
"projects": {
|
||||
"Hacknet": {
|
||||
"projectType": "application",
|
||||
"schematics": {
|
||||
"@schematics/angular:component": {
|
||||
"style": "scss"
|
||||
}
|
||||
},
|
||||
"root": "",
|
||||
"sourceRoot": "src",
|
||||
"prefix": "hn",
|
||||
"architect": {
|
||||
"build": {
|
||||
"builder": "@angular-devkit/build-angular:browser",
|
||||
"options": {
|
||||
"outputPath": "dist/hacknet",
|
||||
"index": "src/index.html",
|
||||
"main": "src/main.ts",
|
||||
"polyfills": [
|
||||
"zone.js"
|
||||
],
|
||||
"tsConfig": "tsconfig.app.json",
|
||||
"inlineStyleLanguage": "scss",
|
||||
"assets": [
|
||||
"src/favicon.ico",
|
||||
"src/assets"
|
||||
],
|
||||
"styles": [
|
||||
"src/scss/styles.scss"
|
||||
],
|
||||
"scripts": []
|
||||
},
|
||||
"configurations": {
|
||||
"production": {
|
||||
"budgets": [
|
||||
{
|
||||
"type": "initial",
|
||||
"maximumWarning": "500kb",
|
||||
"maximumError": "1mb"
|
||||
},
|
||||
{
|
||||
"type": "anyComponentStyle",
|
||||
"maximumWarning": "2kb",
|
||||
"maximumError": "4kb"
|
||||
}
|
||||
],
|
||||
"outputHashing": "all"
|
||||
},
|
||||
"development": {
|
||||
"buildOptimizer": false,
|
||||
"optimization": false,
|
||||
"vendorChunk": true,
|
||||
"extractLicenses": false,
|
||||
"sourceMap": true,
|
||||
"namedChunks": true
|
||||
}
|
||||
},
|
||||
"defaultConfiguration": "production"
|
||||
},
|
||||
"serve": {
|
||||
"builder": "@angular-devkit/build-angular:dev-server",
|
||||
"configurations": {
|
||||
"production": {
|
||||
"browserTarget": "Hacknet:build:production"
|
||||
},
|
||||
"development": {
|
||||
"browserTarget": "Hacknet:build:development"
|
||||
}
|
||||
},
|
||||
"defaultConfiguration": "development"
|
||||
},
|
||||
"extract-i18n": {
|
||||
"builder": "@angular-devkit/build-angular:extract-i18n",
|
||||
"options": {
|
||||
"browserTarget": "Hacknet:build"
|
||||
}
|
||||
},
|
||||
"test": {
|
||||
"builder": "@angular-devkit/build-angular:karma",
|
||||
"options": {
|
||||
"polyfills": [
|
||||
"zone.js",
|
||||
"zone.js/testing"
|
||||
],
|
||||
"tsConfig": "tsconfig.spec.json",
|
||||
"inlineStyleLanguage": "scss",
|
||||
"assets": [
|
||||
"src/favicon.ico",
|
||||
"src/assets"
|
||||
],
|
||||
"styles": [
|
||||
"src/scss/styles.scss"
|
||||
],
|
||||
"scripts": []
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"cli": {
|
||||
"analytics": false
|
||||
}
|
||||
}
|
11951
package-lock.json
generated
Normal file
11951
package-lock.json
generated
Normal file
File diff suppressed because it is too large
Load Diff
41
package.json
Normal file
41
package.json
Normal file
@ -0,0 +1,41 @@
|
||||
{
|
||||
"name": "hacknet",
|
||||
"version": "0.0.0",
|
||||
"scripts": {
|
||||
"ng": "ng",
|
||||
"start": "ng serve",
|
||||
"build": "ng build",
|
||||
"watch": "ng build --watch --configuration development",
|
||||
"test": "ng test"
|
||||
},
|
||||
"private": true,
|
||||
"dependencies": {
|
||||
"@angular/animations": "^15.0.0",
|
||||
"@angular/cdk": "^15.0.3",
|
||||
"@angular/common": "^15.0.0",
|
||||
"@angular/compiler": "^15.0.0",
|
||||
"@angular/core": "^15.0.0",
|
||||
"@angular/forms": "^15.0.0",
|
||||
"@angular/material": "^15.0.3",
|
||||
"@angular/platform-browser": "^15.0.0",
|
||||
"@angular/platform-browser-dynamic": "^15.0.0",
|
||||
"@angular/router": "^15.0.0",
|
||||
"bootstrap": "^5.2.3",
|
||||
"rxjs": "~7.5.0",
|
||||
"tslib": "^2.3.0",
|
||||
"zone.js": "~0.12.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@angular-devkit/build-angular": "^15.0.2",
|
||||
"@angular/cli": "~15.0.2",
|
||||
"@angular/compiler-cli": "^15.0.0",
|
||||
"@types/jasmine": "~4.3.0",
|
||||
"jasmine-core": "~4.5.0",
|
||||
"karma": "~6.4.0",
|
||||
"karma-chrome-launcher": "~3.1.0",
|
||||
"karma-coverage": "~2.2.0",
|
||||
"karma-jasmine": "~5.1.0",
|
||||
"karma-jasmine-html-reporter": "~2.0.0",
|
||||
"typescript": "~4.8.2"
|
||||
}
|
||||
}
|
33
src/app/app.module.ts
Normal file
33
src/app/app.module.ts
Normal file
@ -0,0 +1,33 @@
|
||||
import { NgModule } from '@angular/core';
|
||||
import { BrowserModule } from '@angular/platform-browser';
|
||||
|
||||
import { AppRoutingModule } from './app.routes';
|
||||
import {MaterialModule} from './material.module';
|
||||
|
||||
import { AppComponent } from './containers/app/app.component';
|
||||
import { BrowserAnimationsModule } from '@angular/platform-browser/animations';
|
||||
import {LoginComponent} from "./views/login/login.component";
|
||||
import {NetworksComponent} from "./views/networks/networks.component";
|
||||
import {TerminalComponent} from "./views/terminal/terminal.component";
|
||||
import { ContractsComponent } from './views/contracts/contracts.component';
|
||||
import {FirewallComponent} from './views/firewall/firewall.component';
|
||||
|
||||
@NgModule({
|
||||
declarations: [
|
||||
AppComponent,
|
||||
ContractsComponent,
|
||||
FirewallComponent,
|
||||
LoginComponent,
|
||||
NetworksComponent,
|
||||
TerminalComponent,
|
||||
],
|
||||
imports: [
|
||||
BrowserModule,
|
||||
AppRoutingModule,
|
||||
MaterialModule,
|
||||
BrowserAnimationsModule
|
||||
],
|
||||
providers: [],
|
||||
bootstrap: [AppComponent]
|
||||
})
|
||||
export class AppModule { }
|
21
src/app/app.routes.ts
Normal file
21
src/app/app.routes.ts
Normal file
@ -0,0 +1,21 @@
|
||||
import { NgModule } from '@angular/core';
|
||||
import { RouterModule, Routes } from '@angular/router';
|
||||
import { LoginComponent } from './views/login/login.component';
|
||||
import {NetworksComponent} from "./views/networks/networks.component";
|
||||
import {TerminalComponent} from "./views/terminal/terminal.component";
|
||||
import {ContractsComponent} from "./views/contracts/contracts.component";
|
||||
import {FirewallComponent} from "./views/firewall/firewall.component";
|
||||
|
||||
const routes: Routes = [
|
||||
{path: 'contracts', component: ContractsComponent, data: {title: 'Contracts'}},
|
||||
{path: 'firewall', component: FirewallComponent, data: {title: 'Firewall'}},
|
||||
{path: 'networks', component: NetworksComponent, data: {title: 'Networks'}},
|
||||
{path: 'login', component: LoginComponent, data: {title: 'Login'}},
|
||||
{path: 'cli', component: TerminalComponent, data: {title: 'Terminal'}}
|
||||
];
|
||||
|
||||
@NgModule({
|
||||
imports: [RouterModule.forRoot(routes)],
|
||||
exports: [RouterModule]
|
||||
})
|
||||
export class AppRoutingModule { }
|
35
src/app/containers/app/app.component.html
Normal file
35
src/app/containers/app/app.component.html
Normal file
@ -0,0 +1,35 @@
|
||||
<div class="d-flex flex-column h-100">
|
||||
<mat-toolbar class="p-0">
|
||||
<button mat-icon-button (click)="drawer.toggle()">
|
||||
<mat-icon>menu</mat-icon>
|
||||
</button>
|
||||
<span>Hacknet</span>
|
||||
<span class="mx-auto"></span>
|
||||
<div class="h-100 d-flex align-items-center">
|
||||
<div class="mx-3">{{ 0 | currency }}</div>
|
||||
<button mat-icon-button>
|
||||
<mat-icon>email</mat-icon>
|
||||
</button>
|
||||
<button mat-icon-button>
|
||||
<mat-icon>account_circle</mat-icon>
|
||||
</button>
|
||||
</div>
|
||||
</mat-toolbar>
|
||||
<mat-drawer-container class="flex-grow-1" autosize>
|
||||
<mat-drawer #drawer mode="over">
|
||||
<mat-selection-list [multiple]="false">
|
||||
<ng-container *ngFor="let g of navigation; let last = last">
|
||||
<mat-list-option *ngFor="let n of g" class="me-3" [routerLink]="n.url" (click)="drawer.close()">
|
||||
<mat-icon *ngIf="n.icon" matListItemIcon>{{n.icon}}</mat-icon>
|
||||
{{n.label}}
|
||||
</mat-list-option>
|
||||
<mat-divider></mat-divider>
|
||||
</ng-container>
|
||||
</mat-selection-list>
|
||||
</mat-drawer>
|
||||
|
||||
<div>
|
||||
<router-outlet></router-outlet>
|
||||
</div>
|
||||
</mat-drawer-container>
|
||||
</div>
|
0
src/app/containers/app/app.component.scss
Normal file
0
src/app/containers/app/app.component.scss
Normal file
11
src/app/containers/app/app.component.ts
Normal file
11
src/app/containers/app/app.component.ts
Normal file
@ -0,0 +1,11 @@
|
||||
import { Component } from '@angular/core';
|
||||
import {navigation} from '../../models/navigation';
|
||||
|
||||
@Component({
|
||||
selector: 'hn-root',
|
||||
templateUrl: './app.component.html',
|
||||
styleUrls: ['./app.component.scss']
|
||||
})
|
||||
export class AppComponent {
|
||||
navigation = navigation;
|
||||
}
|
30
src/app/material.module.ts
Normal file
30
src/app/material.module.ts
Normal file
@ -0,0 +1,30 @@
|
||||
import { NgModule } from "@angular/core";
|
||||
import {MatSidenavModule} from "@angular/material/sidenav";
|
||||
import {MatListModule} from "@angular/material/list";
|
||||
import {MatIconModule} from "@angular/material/icon";
|
||||
import {MatProgressBarModule} from "@angular/material/progress-bar";
|
||||
import { MatDividerModule } from "@angular/material/divider";
|
||||
import {MatToolbarModule} from "@angular/material/toolbar";
|
||||
import {MatButtonModule} from "@angular/material/button";
|
||||
import {MatFormFieldModule} from "@angular/material/form-field";
|
||||
import {MatInputModule} from "@angular/material/input";
|
||||
import {MatCheckboxModule} from "@angular/material/checkbox";
|
||||
|
||||
const modules: any[] = [
|
||||
MatButtonModule,
|
||||
MatCheckboxModule,
|
||||
MatDividerModule,
|
||||
MatFormFieldModule,
|
||||
MatIconModule,
|
||||
MatInputModule,
|
||||
MatListModule,
|
||||
MatProgressBarModule,
|
||||
MatSidenavModule,
|
||||
MatToolbarModule,
|
||||
];
|
||||
|
||||
@NgModule({
|
||||
imports: modules,
|
||||
exports: modules
|
||||
})
|
||||
export class MaterialModule { }
|
22
src/app/models/navigation.ts
Normal file
22
src/app/models/navigation.ts
Normal file
@ -0,0 +1,22 @@
|
||||
export type NavigationItem = {
|
||||
disabled?: boolean,
|
||||
icon?: string,
|
||||
label: string,
|
||||
url?: string | string[]
|
||||
}
|
||||
|
||||
export const navigation: NavigationItem[][] = [
|
||||
[
|
||||
{icon: 'home', label: 'Home', url: '/'},
|
||||
{icon: 'request_quote', label: 'Contracts', url: '/contracts'},
|
||||
], [
|
||||
{icon: 'wifi', label: 'Networks', url: '/networks'},
|
||||
{icon: 'local_fire_department', label: 'Firewall', url: '/firewall'},
|
||||
{icon: 'dns', label: 'Servers', url: '/servers'},
|
||||
], [
|
||||
{icon: 'code', label: 'Scripts', url: '/scripts'},
|
||||
{icon: 'terminal', label: 'Terminal', url: '/cli'},
|
||||
], [
|
||||
|
||||
]
|
||||
];
|
15
src/app/views/contracts/contracts.component.html
Normal file
15
src/app/views/contracts/contracts.component.html
Normal file
@ -0,0 +1,15 @@
|
||||
<h1 class="ms-3">
|
||||
<mat-icon class="me-2">request_quote</mat-icon>
|
||||
Contracts
|
||||
</h1>
|
||||
<mat-divider></mat-divider>
|
||||
<div>
|
||||
<mat-selection-list [multiple]="false">
|
||||
<mat-list-option *ngFor="let c of contracts">
|
||||
<mat-icon matListItemIcon class="me-3">{{c.icon}}</mat-icon>
|
||||
<div class="fw-bold">{{c.name}}</div>
|
||||
<div>{{c.description}}</div>
|
||||
<div *ngIf="c.accepted" class="text-muted">Accepted</div>
|
||||
</mat-list-option>
|
||||
</mat-selection-list>
|
||||
</div>
|
23
src/app/views/contracts/contracts.component.ts
Normal file
23
src/app/views/contracts/contracts.component.ts
Normal file
@ -0,0 +1,23 @@
|
||||
import { Component } from "@angular/core";
|
||||
|
||||
export type Contract = {
|
||||
icon: string,
|
||||
name: string,
|
||||
description: string,
|
||||
accepted?: boolean
|
||||
}
|
||||
|
||||
@Component({
|
||||
selector: 'hn-contracts',
|
||||
templateUrl: './contracts.component.html'
|
||||
})
|
||||
export class ContractsComponent {
|
||||
contracts: Contract[] = [
|
||||
{icon: 'wifi_disable', name: 'Crack Network', description: 'Gain unauthorized access to a network'},
|
||||
{icon: 'currency_bitcoin', name: 'Steel Wallet', description: 'Hack into a server & retrieve a crypto-wallet'},
|
||||
{icon: 'bug_report', name: 'Deploy Trojan', description: 'Gain full access to a target server'},
|
||||
{icon: 'keyboard_hide', name: 'Deploy Keylogger', description: 'Deploy a keylogger to collect valuable intel'},
|
||||
{icon: 'delete', name: 'Delete Data', description: 'Delete some sensitive files on a remove server'},
|
||||
{icon: 'file_copy', name: 'Steel Data', description: 'Copy some sensitive data without being detected'},
|
||||
]
|
||||
}
|
23
src/app/views/firewall/firewall.component.html
Normal file
23
src/app/views/firewall/firewall.component.html
Normal file
@ -0,0 +1,23 @@
|
||||
<h1 class="ms-3">
|
||||
<mat-icon>local_fire_department</mat-icon>
|
||||
Firewall
|
||||
</h1>
|
||||
<mat-divider></mat-divider>
|
||||
<div class="d-flex align-items-center">
|
||||
<div class="p-3">
|
||||
<mat-form-field apperence="fill">
|
||||
<mat-label>Rule Name</mat-label>
|
||||
<input matInput type="text">
|
||||
</mat-form-field>
|
||||
</div>
|
||||
<div class="p-3">
|
||||
<mat-form-field apperence="fill">
|
||||
<mat-label>Port</mat-label>
|
||||
<input matInput type="number">
|
||||
</mat-form-field>
|
||||
</div>
|
||||
<div class="pb-3">
|
||||
<mat-checkbox [checked]="true">Enabled</mat-checkbox>
|
||||
</div>
|
||||
</div>
|
||||
<a class="p-3 text-decoration-underline">+ New Rule</a>
|
7
src/app/views/firewall/firewall.component.ts
Normal file
7
src/app/views/firewall/firewall.component.ts
Normal file
@ -0,0 +1,7 @@
|
||||
import { Component } from "@angular/core";
|
||||
|
||||
@Component({
|
||||
selector: 'hn-firewall',
|
||||
templateUrl: './firewall.component.html',
|
||||
})
|
||||
export class FirewallComponent { }
|
17
src/app/views/login/login.component.html
Normal file
17
src/app/views/login/login.component.html
Normal file
@ -0,0 +1,17 @@
|
||||
<div class="d-flex justify-content-center mt-5 pt-5">
|
||||
<div class="d-flex flex-column align-items-center">
|
||||
<mat-icon style="font-size: 36px; height: 36px; width: 36px">web</mat-icon>
|
||||
<mat-form-field class="mt-3">
|
||||
<mat-label>Username</mat-label>
|
||||
<input matInput type="text">
|
||||
</mat-form-field>
|
||||
<mat-form-field class="mt-3">
|
||||
<mat-label>Password</mat-label>
|
||||
<input matInput type="password">
|
||||
</mat-form-field>
|
||||
<div class="d-flex w-100 mt-3 justify-content-between">
|
||||
<button mat-button>Register</button>
|
||||
<button mat-raised-button>Login</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
7
src/app/views/login/login.component.ts
Normal file
7
src/app/views/login/login.component.ts
Normal file
@ -0,0 +1,7 @@
|
||||
import {Component} from '@angular/core';
|
||||
|
||||
@Component({
|
||||
selector: 'hn-login',
|
||||
templateUrl: './login.component.html'
|
||||
})
|
||||
export class LoginComponent { }
|
29
src/app/views/networks/networks.component.html
Normal file
29
src/app/views/networks/networks.component.html
Normal file
@ -0,0 +1,29 @@
|
||||
<h1 class="ms-3">
|
||||
<mat-icon class="me-2">wifi</mat-icon>
|
||||
Networks
|
||||
</h1>
|
||||
<mat-progress-bar mode="indeterminate"></mat-progress-bar>
|
||||
<div>
|
||||
<mat-selection-list [multiple]="false">
|
||||
<mat-list-option *ngIf="connected" selected>
|
||||
<mat-icon matListItemIcon>network_wifi_{{connected.strength}}_bar</mat-icon>
|
||||
{{connected.name}}
|
||||
<div class="text-muted">Connected</div>
|
||||
</mat-list-option>
|
||||
<mat-list-option *ngFor="let n of discovered">
|
||||
<mat-icon matListItemIcon>network_wifi_{{n.strength}}_bar</mat-icon>
|
||||
{{n.name}}
|
||||
</mat-list-option>
|
||||
</mat-selection-list>
|
||||
</div>
|
||||
<h2 class="ms-3">
|
||||
<mat-icon class="me-2">vpn_key</mat-icon>
|
||||
VPN
|
||||
</h2>
|
||||
<mat-divider></mat-divider>
|
||||
<mat-list>
|
||||
<mat-list-item *ngFor="let n of tunnled">
|
||||
<mat-icon matListItemIcon>link</mat-icon>
|
||||
{{n.name}}
|
||||
</mat-list-item>
|
||||
</mat-list>
|
22
src/app/views/networks/networks.component.ts
Normal file
22
src/app/views/networks/networks.component.ts
Normal file
@ -0,0 +1,22 @@
|
||||
import { Component } from "@angular/core";
|
||||
|
||||
export type Network = {
|
||||
strength: number,
|
||||
name: string,
|
||||
}
|
||||
|
||||
@Component({
|
||||
selector: 'hn-networks',
|
||||
templateUrl: './networks.component.html'
|
||||
})
|
||||
export class NetworksComponent {
|
||||
connected: Network = {strength: 3, name: 'OutraNet'}
|
||||
discovered: Network[] = [
|
||||
{strength: 4, name: 'SkyNet'},
|
||||
{strength: 2, name: 'FBI Survelence Van'},
|
||||
{strength: 3, name: 'Bat Cave'},
|
||||
]
|
||||
tunnled: Network[] = [
|
||||
{strength: 3, name: 'Bat Cave'},
|
||||
]
|
||||
}
|
141
src/app/views/terminal/terminal.component.html
Normal file
141
src/app/views/terminal/terminal.component.html
Normal file
@ -0,0 +1,141 @@
|
||||
<style>
|
||||
.console {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
padding: 1rem;
|
||||
}
|
||||
|
||||
.console-input {
|
||||
display: flex;
|
||||
}
|
||||
|
||||
.console-input-prompt {
|
||||
padding-right: 0.55em;
|
||||
}
|
||||
|
||||
.console-input-field {
|
||||
border: none;
|
||||
outline: none;
|
||||
font-size: 1rem;
|
||||
background-color: rgba(0, 0, 0, 0);
|
||||
color: #0f0;
|
||||
font-family: monospace;
|
||||
flex-grow: 1;
|
||||
padding: 0;
|
||||
}
|
||||
|
||||
.console-output {
|
||||
flex-grow: 1;
|
||||
}
|
||||
|
||||
.console-output-line {
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
min-height: 1.25rem;
|
||||
}
|
||||
</style>
|
||||
<script>
|
||||
window.cli = {};
|
||||
</script>
|
||||
<script>
|
||||
window.cli['clear'] = {
|
||||
autocomplete: () => {
|
||||
return [];
|
||||
},
|
||||
help: () => {
|
||||
return 'Clear console output';
|
||||
},
|
||||
run: args => {
|
||||
output.innerHTML = '';
|
||||
}
|
||||
}
|
||||
</script>
|
||||
<script>
|
||||
window.cli['echo'] = {
|
||||
autocomplete: () => {
|
||||
return [];
|
||||
},
|
||||
help: () => {
|
||||
return 'Output text to console';
|
||||
},
|
||||
run: args => {
|
||||
return args.join(' ');
|
||||
}
|
||||
}
|
||||
</script>
|
||||
<script>
|
||||
window.cli['exit'] = {
|
||||
autocomplete: () => {
|
||||
return [];
|
||||
},
|
||||
help: () => {
|
||||
return 'End session';
|
||||
},
|
||||
run: args => {
|
||||
process('clear');
|
||||
history = [];
|
||||
historyIndex = 0;
|
||||
header();
|
||||
}
|
||||
}
|
||||
</script>
|
||||
<script>
|
||||
window.cli['help'] = {
|
||||
autocomplete: () => {
|
||||
return [];
|
||||
},
|
||||
help: () => {
|
||||
return 'Display all commands';
|
||||
},
|
||||
run: args => {
|
||||
return Object.keys(window.cli).map(command => `${command} - ${window.cli[command].help()}`).join('<br>') + '<br><br>';
|
||||
}
|
||||
}
|
||||
</script>
|
||||
<script>
|
||||
window.cli['hostname'] = {
|
||||
autocomplete: () => {
|
||||
return [];
|
||||
},
|
||||
help: () => {
|
||||
return 'Get computer hostname';
|
||||
},
|
||||
run: args => {
|
||||
return 'localhost'
|
||||
}
|
||||
}
|
||||
</script>
|
||||
<script>
|
||||
window.cli['man'] = {
|
||||
autocomplete: () => {
|
||||
return [];
|
||||
},
|
||||
help: () => {
|
||||
return 'Command manual';
|
||||
},
|
||||
run: args => {
|
||||
return window.cli[args[0]].help();
|
||||
}
|
||||
}
|
||||
</script>
|
||||
<script>
|
||||
window.cli['whoami'] = {
|
||||
autocomplete: () => {
|
||||
return [];
|
||||
},
|
||||
help: () => {
|
||||
return 'Get username';
|
||||
},
|
||||
run: args => {
|
||||
return 'root'
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<div class="console" (click)="inputEl.focus()">
|
||||
<div class="console-output"></div>
|
||||
<div class="console-input">
|
||||
<div class="console-input-prompt">root@localhost:~ #</div>
|
||||
<input #inputEl class="console-input-field" type="text" autofocus (blur)="inputEl.focus()" (keyup.enter)="enter()">
|
||||
</div>
|
||||
</div>
|
97
src/app/views/terminal/terminal.component.ts
Normal file
97
src/app/views/terminal/terminal.component.ts
Normal file
@ -0,0 +1,97 @@
|
||||
import {AfterViewInit, Component} from "@angular/core";
|
||||
|
||||
@Component({
|
||||
selector: 'hn-terminal',
|
||||
templateUrl: './terminal.component.html'
|
||||
})
|
||||
export class TerminalComponent implements AfterViewInit {
|
||||
output: any;
|
||||
input: any;
|
||||
|
||||
history: string[] = [];
|
||||
historyIndex = 0;
|
||||
|
||||
ngAfterViewInit() {
|
||||
this.output = document.getElementsByClassName('console-output')[0];
|
||||
this.input = document.getElementsByClassName('console-input-field')[0];
|
||||
setTimeout(() => this.banner(), 1000);
|
||||
}
|
||||
|
||||
banner() {
|
||||
this.stdOut('Konsole 0.1.0 LTS localhost tty1<br><br>localhost login: root<br>password:<br><br>');
|
||||
}
|
||||
|
||||
disableInput() {
|
||||
this.input.disabled = true;
|
||||
// document.getElementsByClassName('console-input-prompt')[0].style.visibility = 'hidden';
|
||||
}
|
||||
|
||||
enableInput() {
|
||||
this.input.disabled = false;
|
||||
this.input.focus();
|
||||
// document.getElementsByClassName('console-input-prompt')[0].style.visibility = 'visible';
|
||||
}
|
||||
|
||||
process(command: string) {
|
||||
(Array.isArray(command) ? command.join(' ') : command).split(';').filter(c => !!c).forEach(c => {
|
||||
const parts = c.split(' ').filter(c => !!c);
|
||||
if((<any>window).cli[parts[0]] == undefined || (<any>window).cli[parts[0]].run == undefined) {
|
||||
this.stdErr(`${parts[0]}: command not found`);
|
||||
} else {
|
||||
try {
|
||||
const out = (<any>window).cli[parts[0]].run(parts.slice(1));
|
||||
if(!!out) this.stdOut(out);
|
||||
} catch(err) {
|
||||
console.error(err)
|
||||
this.stdErr(`${parts[0]}: exited with a non-zero status`);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
stdErr(text: string) {
|
||||
const p: any = document.createElement('p');
|
||||
p.classList = 'console-output-line error';
|
||||
p.innerText = text;
|
||||
this.output.appendChild(p);
|
||||
}
|
||||
|
||||
stdOut(text: string, html=true) {
|
||||
const p: any = document.createElement('p');
|
||||
p.classList = 'console-output-line';
|
||||
p[html ? 'innerHTML' : 'innerText'] = text;
|
||||
this.output.appendChild(p);
|
||||
}
|
||||
|
||||
enter() {
|
||||
this.disableInput();
|
||||
const inputValue: string = this.input.value;
|
||||
this.input.value = '';
|
||||
this.stdOut(`root@localhost:~ # ${inputValue}`, false);
|
||||
if(!!inputValue) {
|
||||
this.history.push(inputValue);
|
||||
this.historyIndex = history.length;
|
||||
this.process(inputValue)
|
||||
}
|
||||
this.enableInput();
|
||||
// if(event.key == "Enter") {
|
||||
//
|
||||
// } else if(event.key == 'Up' || event.key == 'ArrowUp') {
|
||||
// if(historyIndex > 0) historyIndex--;
|
||||
// input.value = historyIndex == history.length ? '' : history[historyIndex];
|
||||
// setTimeout(() => {
|
||||
// const end = input.value.length;
|
||||
// input.setSelectionRange(end, end);
|
||||
// input.focus();
|
||||
// }, 1)
|
||||
// } else if(event.key == 'Down' || event.key == 'ArrowDown') {
|
||||
// if(historyIndex < history.length) historyIndex++;
|
||||
// input.value = historyIndex == history.length ? '' : history[historyIndex];
|
||||
// setTimeout(() => {
|
||||
// const end = input.value.length;
|
||||
// input.setSelectionRange(end, end);
|
||||
// input.focus();
|
||||
// }, 1)
|
||||
// }
|
||||
}
|
||||
}
|
0
src/assets/.gitkeep
Normal file
0
src/assets/.gitkeep
Normal file
BIN
src/favicon.ico
Normal file
BIN
src/favicon.ico
Normal file
Binary file not shown.
After Width: | Height: | Size: 948 B |
16
src/index.html
Normal file
16
src/index.html
Normal file
@ -0,0 +1,16 @@
|
||||
<!doctype html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<title>Hacknet</title>
|
||||
<base href="/">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||
<link rel="icon" type="image/x-icon" href="favicon.ico">
|
||||
<link rel="preconnect" href="https://fonts.gstatic.com">
|
||||
<link href="https://fonts.googleapis.com/css2?family=Roboto:wght@300;400;500&display=swap" rel="stylesheet">
|
||||
<link href="https://fonts.googleapis.com/icon?family=Material+Icons" rel="stylesheet">
|
||||
</head>
|
||||
<body class="mat-typography">
|
||||
<hn-root></hn-root>
|
||||
</body>
|
||||
</html>
|
7
src/main.ts
Normal file
7
src/main.ts
Normal file
@ -0,0 +1,7 @@
|
||||
import { platformBrowserDynamic } from '@angular/platform-browser-dynamic';
|
||||
|
||||
import { AppModule } from './app/app.module';
|
||||
|
||||
|
||||
platformBrowserDynamic().bootstrapModule(AppModule)
|
||||
.catch(err => console.error(err));
|
12
src/scss/bootstrap.scss
vendored
Normal file
12
src/scss/bootstrap.scss
vendored
Normal file
@ -0,0 +1,12 @@
|
||||
@import '../../node_modules/bootstrap/dist/css/bootstrap-utilities.min.css';
|
||||
|
||||
:root {
|
||||
--bs-primary: #0d6efd;
|
||||
--bs-secondary: #6c757d;
|
||||
--bs-success: #198754;
|
||||
--bs-info: #0dcaf0;
|
||||
--bs-warning: #ffc107;
|
||||
--bs-danger: #dc3545;
|
||||
--bs-light: #f8f9fa;
|
||||
--bs-dark: #212529;
|
||||
}
|
33
src/scss/material.scss
Normal file
33
src/scss/material.scss
Normal file
@ -0,0 +1,33 @@
|
||||
// Custom Theming for Angular Material
|
||||
// For more information: https://material.angular.io/guide/theming
|
||||
@use '@angular/material' as mat;
|
||||
// Plus imports for other components in your app.
|
||||
|
||||
// Include the common styles for Angular Material. We include this here so that you only
|
||||
// have to load a single css file for Angular Material in your app.
|
||||
// Be sure that you only ever include this mixin once!
|
||||
@include mat.core();
|
||||
|
||||
// Define the palettes for your theme using the Material Design palettes available in palette.scss
|
||||
// (imported above). For each palette, you can optionally specify a default, lighter, and darker
|
||||
// hue. Available color palettes: https://material.io/design/color/
|
||||
$Hacknet-primary: mat.define-palette(mat.$indigo-palette);
|
||||
$Hacknet-accent: mat.define-palette(mat.$pink-palette, A200, A100, A400);
|
||||
|
||||
// The warn palette is optional (defaults to red).
|
||||
$Hacknet-warn: mat.define-palette(mat.$red-palette);
|
||||
|
||||
// Create the theme object. A theme consists of configurations for individual
|
||||
// theming systems such as "color" or "typography".
|
||||
$Hacknet-theme: mat.define-dark-theme((
|
||||
color: (
|
||||
primary: $Hacknet-primary,
|
||||
accent: $Hacknet-accent,
|
||||
warn: $Hacknet-warn,
|
||||
)
|
||||
));
|
||||
|
||||
// Include theme styles for core and each component used in your app.
|
||||
// Alternatively, you can import and @include the theme mixins for each component
|
||||
// that you are using.
|
||||
@include mat.all-component-themes($Hacknet-theme);
|
5
src/scss/styles.scss
Normal file
5
src/scss/styles.scss
Normal file
@ -0,0 +1,5 @@
|
||||
@import "material";
|
||||
@import "bootstrap";
|
||||
|
||||
html, body { height: 100%; }
|
||||
body { margin: 0; font-family: Roboto, "Helvetica Neue", sans-serif; }
|
14
tsconfig.app.json
Normal file
14
tsconfig.app.json
Normal file
@ -0,0 +1,14 @@
|
||||
/* To learn more about this file see: https://angular.io/config/tsconfig. */
|
||||
{
|
||||
"extends": "./tsconfig.json",
|
||||
"compilerOptions": {
|
||||
"outDir": "./out-tsc/app",
|
||||
"types": []
|
||||
},
|
||||
"files": [
|
||||
"src/main.ts"
|
||||
],
|
||||
"include": [
|
||||
"src/**/*.d.ts"
|
||||
]
|
||||
}
|
33
tsconfig.json
Normal file
33
tsconfig.json
Normal file
@ -0,0 +1,33 @@
|
||||
/* To learn more about this file see: https://angular.io/config/tsconfig. */
|
||||
{
|
||||
"compileOnSave": false,
|
||||
"compilerOptions": {
|
||||
"baseUrl": "./",
|
||||
"outDir": "./dist/out-tsc",
|
||||
"forceConsistentCasingInFileNames": true,
|
||||
"strict": true,
|
||||
"noImplicitOverride": true,
|
||||
"noPropertyAccessFromIndexSignature": true,
|
||||
"noImplicitReturns": true,
|
||||
"noFallthroughCasesInSwitch": true,
|
||||
"sourceMap": true,
|
||||
"declaration": false,
|
||||
"downlevelIteration": true,
|
||||
"experimentalDecorators": true,
|
||||
"moduleResolution": "node",
|
||||
"importHelpers": true,
|
||||
"target": "ES2022",
|
||||
"module": "ES2022",
|
||||
"useDefineForClassFields": false,
|
||||
"lib": [
|
||||
"ES2022",
|
||||
"dom"
|
||||
]
|
||||
},
|
||||
"angularCompilerOptions": {
|
||||
"enableI18nLegacyMessageIdFormat": false,
|
||||
"strictInjectionParameters": true,
|
||||
"strictInputAccessModifiers": true,
|
||||
"strictTemplates": true
|
||||
}
|
||||
}
|
14
tsconfig.spec.json
Normal file
14
tsconfig.spec.json
Normal file
@ -0,0 +1,14 @@
|
||||
/* To learn more about this file see: https://angular.io/config/tsconfig. */
|
||||
{
|
||||
"extends": "./tsconfig.json",
|
||||
"compilerOptions": {
|
||||
"outDir": "./out-tsc/spec",
|
||||
"types": [
|
||||
"jasmine"
|
||||
]
|
||||
},
|
||||
"include": [
|
||||
"src/**/*.spec.ts",
|
||||
"src/**/*.d.ts"
|
||||
]
|
||||
}
|
Loading…
Reference in New Issue
Block a user