This repository has been archived on 2024-04-03. You can view files and clone it, but cannot push or open issues or pull requests.
OLD-GZod01.fr_Source_Code-OLD/main-site/CyberTermHack/V0.2/maincode.js

427 lines
16 KiB
JavaScript
Raw Normal View History

2023-03-25 09:29:34 +00:00
var x = ""
function splitaddr(complete, cmd){
try{
let c = complete.substring(cmd.length)
let u = c.split('@')[0]
let a = c.split('@')[1]
if (a==undefined){
termshow('Please complete the command like this: '+cmd+' user@address')
return 'ERROR'
}
else{
return [u, a]
}
}
catch(e){
console.error(e)
termshow('Please complete the command like this: '+cmd+' user@address')
return 'ERROR'
}
}
function infos(){
termshow('01010101010101010\n1.CyberTermGame.1\n0.....By GZod01.....0\n10101010101010101\nInfos on the game : Hello my name is GZod01 and i make this game in javascript (base game in python) "for fun", I know this game is not reflecting the reality of the command on linux or windows machines but... it is a game...\nSorry if the english is not very good i speak french...')
}
stopmatrix()
var passwordlist = ["my_password","helloworld","ultra_secure_password","my_birthday"]
var filelist = ['picture.png','personnal_datas.csv', 'helloworld.py','i_hate_hackers.txt','speech_for_tomorrow.md', '.ha_ha_this_is_super_secret_file.txt','mydirectory/']
var connected = false
var datased = false
var STOP = false
infos()
var user = ""
var ip = ""
var password = ""
var destroyedip = []
var codeline = ["fn destroy(oiaf){executeshellcomand('destroy oiaf')}","hack-server()","destroy()","fn hack-server(files){for(var i = 0, i<len(files)){if (type_of_file(files[i])==='password_files_and_datas_files'){execcommand('copyfile_to_my_computer'); destroy(files)};", "print(01020003957058098409438409340&àà_09232983983983923999832983928398329389238938923892382938923899201809381093809é'802984029804802948049820840938éàç8309é_à'ç_éà'_09790872çà'àç_éè409724097240942èàçé'8è290479024798047298047904èé4908éè4) in serverdatas"]
termshow('starting session ...')
var me = ''
var list_of_command = ['ls','ssh','pbk','exit','theme','matrix','hack','attack','save','import','help','exit']
function autocomplete(){
let inptval = document.getElementById('terminpt').value
termshow('List of available commands starting with " '+inptval+' " :')
for(let i = 0; i<list_of_command.length; i++){
if(list_of_command[i].startsWith(inptval)){
termshow('- '+list_of_command[i])
}
}
}
named = false
// example of serversdatas: "ip":{"destroyed":true (or false), "files":listoffiles, "password":"password"}
var gamedatas = {
"serversdatas":{},
"username": me,
'colorscheme': 'default' //it can be green / red / blue / yellow
}
// START OF MAIN-MODE CODE
function gettheme(){
let r = document.querySelector(':root')
if (gamedatas.colorscheme ==='default'){
r.style.setProperty('--txt-color','white')
}
else if (gamedatas.colorscheme === 'green'){
r.style.setProperty('--txt-color','green')
}
else if (gamedatas.colorscheme === 'red'){
r.style.setProperty('--txt-color','red')
}
else if (gamedatas.colorscheme === 'blue'){
r.style.setProperty('--txt-color','blue')
}
else if (gamedatas.colorscheme === 'yellow'){
r.style.setProperty('--txt-color','yellow')
}
}
var ipdatas = {}
document.getElementById('terminpt').focus()
async function loop(){
gamedatas.serversdatas = ipdatas
if(named){
if(connected){
x = terminput(`${user}@${ip} $ `)
}
else{
x = terminput(`${me}@MYCOMPUTER # `)
}
if(x==='ERR'){}
else{
//historic.push(x)
lastx = x
let lowx = x.toLowerCase()
if(connected){
termshow(`${user}@${ip} $ ${x}`)
}
else{
termshow(`${me}@MYCOMPUTER # ${x}`)
}
if (lowx.startsWith('ssh')){
hackssh(x)
}
else if (lowx.startsWith('pbk')){
hackpbk(x)
}
else if (lowx.startsWith('theme')){
hacktheme(x)
}
else if (lowx.startsWith('matrix')){
hackmatrix(x)
}
else if(lowx==='save'){
hacksave()
}
else if(lowx==='import'){
hackimport()
}
else if (lowx=='ls'){
hackls()
}
else if (lowx=='attack'){
hackattack()
}
else if( x==='help'){
hackhelp()
}
else if (lowx==='exit'){
hackexit()
}
else if (lowx==='hack'){
hackhack()
}
else if (lowx=='infos'){
infos()
}
else if(x.startsWith('$$$')){
execjscode(x)
}
}
}
else{
let temp = terminput('your name: ')
if(temp.length<4){
document.getElementById('inptindic').innerHTML ='your name must have more than 4 characters '
}
else{
me = temp
named = true
document.getElementById('inptindic').innerHTML=''
}
}
window.requestAnimationFrame(loop)
}
loop()
//----------------------------------------------------------------------------------------------
//END OF MAIN-MODE CODE
// START OF COMMAND FUNCTIONS
async function execjscode(cx){
if(cx === '$$$' || cx === '$$$ '){
termshow('this command is for execute js code enter your js code after the $$$')
}
else{
try{
let tempcode = cx.substring('$$$ '.length)
let newfunc = new Function (tempcode)
newfunc()
}
catch(e){
termshow('Il y a eu une erreur : '+e)
}
}
}
async function hackhack(){
if (connected){
termshow('--Start-of-the-hacking-program--')
for(let i = 0; i<randint(0,50);i++){
termshow(randchoice(codeline))
}
}
else{
termshow('you have to be connected')
}
}
async function hackexit(){
if (connected){
termshow('disconnecting...')
connected=false
}
else{
termshow('Exiting the session...')
termshow('Exiting the game, thank to play to this game, don\'t hesitate to help me or to give me your feedback')
STOP = true
location = '/'
}
}
function hackhelp(){
termshow('The available commands: \n- help : print this message\n- ls : list the files and folders\n- pbk (only in your computer) : Get the password of an user from an ip address\n- ssh (only in your computer) : conect to a distant server with an user and an ip address (you have to use pbk to get the password)\n- attack (only in ssh servers) : start an attack that will add all the datas on the server in your servers_data.zip file and will destroy the server (warning this will no destroy only the server from the user it will destroy ALL the server (the address))\n- theme : switch the theme of the game\n- save : save the game in your localStorage (alternative to cookies)\n- import : import the game from your localStorage\n- matrix : start or stop a matrix rain animation (just for fun...)\n- exit : if you are connected to distant server (ssh) it deconnect you, if you are not connected it exit this game\n- infos : display infos on this game')
}
async function hackattack(){
if( connected){
termshow('the attack start... \n copying all the data in this server to your servers_data.zip file in your computer (it include all the file, folder etc.)...\nbreaking the server...\nDisconnected: The server is destroy')
connected = false
datased = true
ipdatas[ip]['destroyed'] = true
}
else{
termshow('error you are not connected, please connect to a distant server before executing this command')
}
}
async function hackls(){
if (connected){
if (ipdatas[ip]['files'] == undefined){
termshow('This is the file on the distant machine')
let fileiplist = []
for(let i=0; i < parseInt(randint(1,10)); i++){
let currentchoicefile = randchoice(filelist)
termshow('-'+currentchoicefile)
fileiplist.push(currentchoicefile)
}
ipdatas[ip]['files'] = fileiplist
}
else{
termshow('This is the file on the distant machine')
for(let i = 0; i<ipdatas[ip]['files'].length; i++){
termshow('-'+ ipdatas[ip]['files'][i])
}
}
}
else{
if (datased){
termshow('This is the file on your computer: \n- my_datas.zip \n- servers_data.zip')
}
else{
termshow('This is the file on your computer: \n- my_datas.zip')
}
}
}
async function hackimport(){
let tmpdatas = localStorage.getItem('hackergamedatas')
if (tmpdatas == undefined){
termshow('you don\'t have any data saved, please execute the save command before to import')
}
else{
gamedatas = JSON.parse(tmpdatas)
}
}
function hacksave(){
localStorage.setItem('hackergamedatas',JSON.stringify(gamedatas))
termshow('Data saved')
termshow(localStorage.getItem('hackergamedatas'))
}
function hackmatrix(lowx){
if(lowx==='matrix'||lowx==='matrix '){
matrix(gamedatas.colorscheme)
}
else{
let nx = x.substring('matrix '.length)
if(nx==='yellow' || nx ==='blue' || nx==='white' || nx ==='red' || nx === 'green'||nx=='purple'|| nx=='cyan' || nx=='magenta'){
matrix(nx)
}
else if(nx==='stop'){
stopmatrix()
}
else{
termshow('Switch the theme with this command,\n the available colors are : default , yellow , red , blue , green . \n execute the command like this: theme default or theme yellow , etc.')
}
}
}
function hacktheme(lowx){
if(lowx==='theme'||lowx==='theme '){
termshow('Switch the theme with this command,\n the available colors are : default , yellow , red , blue , green . \n execute the command like this: theme default or theme yellow , etc.')
}
else{
let nx = x.substring('theme '.length)
if(nx==='yellow' || nx ==='blue' || nx==='default' || nx ==='red' || nx === 'green'){
gamedatas.colorscheme = nx
gettheme()
}
else{
termshow('Switch the theme with this command,\n the available colors are : default , yellow , red , blue , green . \n execute the command like this: theme default or theme yellow , etc.')
}
}
}
async function hackpbk(x){
if (connected){
termshow('error you are on a distant server')
}
else{
if (splitaddr(x,'pbk')==='ERROR'){
splitaddr(x,'pbk')
}
else{
user=splitaddr(x, 'pbk')[0]
ip = splitaddr(x, 'pbk')[1]
if(ipdatas[ip]==undefined){
ipdatas[ip]={}
}
termshow('Breaking the password of the user '+user+' to the computer with the ip '+ip+' ...')
password= randchoice(passwordlist)
ipdatas[ip]['password']=password
termshow('The password is : '+ password)
}
}
}
async function hackssh(x){
if (connected){
termshow('error you already are in distant server')
}
else{
if (splitaddr(x, 'ssh') === 'ERROR'){
}
else{
user = splitaddr(x, 'ssh')[0]
ip = splitaddr(x, 'ssh')[1]
if(ipdatas[ip]==undefined){
ipdatas[ip]={}
}
termshow('connect to the computer with the ip '+ip+' from the user '+user+' ...')
if (ipdatas[ip]['destroyed']){
termshow('error this server is destroyed')
}
else{
if(ipdatas[ip]['password']==undefined){
termshow('you don\'t have the password of this server')
}
else{
await sleep(1)
termshow('Password: AUTOMATIC_PASSWORD_SYSTEM')
// while(temppass != ipdatas[ip]['password']){
// temppass = terminput('Password: ')
// }
await sleep(1)
termshow('connected')
connected=true
}
}
}
}
}
//----------------------------------------------------------------------------------------------------------------
// END OF COMMAND FUNCTIONS
if(true){}
else{
//START OF INGAME PROGRAM CODES
//sorry it is too difficult to create
//t and x for transform and execute
function tandx(code, originactions={'ALERTME':'','ADD':''}){
let lcode = code.split('\n')
for(let i =0; i<lcode.length; i++){
if(lcode==='ALERTME'){
termshow('ALERT : '+originactions['ALERTME'])
}
else if(lcode==='ADD'){
try{
new Function(originactions['ADD'])()
}
catch(e){cwarn('ERREUR DANS LE CODE SOURCE: '+e)}
}
}
}
var listofconnected = []
var connectedevent = {
'name':'',
'ip':''
}
function on_connected_to_me(code){
let actions={
'ALERTME': 'ALERT SOMEONE CONNECT TO YOU',
'ADD':'listofconnected.push(connectedevent.name+";"+connectedevent.ip")'
}
tandx(code, actions)
}
// END OF REAL PROGRAM CODES
// sorry it's very difficult
//START OF STORY MODE CODE
var lifes = 3
function storyloop(condition, toexecute, quantity_of_try=3){
x = terminput(me+'@'+'storymode')
let trys=0
if(x==='ERR'){}
else{
if(condition){
toexecute()
}
else{
quantity
}
}
}
async function chap1m1(){
termshow('WELCOME TO THE STORY MODE')
await sleep(2)
termshow('NOW YOU WILL HAVE TO HACK A SERVER')
await sleep(2)
termshow('SORRY YOU DON\'T KNOW WHO I AM')
await sleep(0.5)
termshow('MY NAME IS HACKIA AND I\'M AN IA CREATED TO HELP THE HACKER BEGINNER')
termshow('NOW SSH TO THE SERVER AT THE IP 1234.5678.9012 FROM THE USER ROBERT (type ssh name_of_user@ip_of_server)')
}
// END OF STORY MODE CODE
}