@@ -25,6 +25,7 @@ function Terminal() {
2525 const [ isSSH , setIsSSH ] = useState ( false ) ;
2626 const [ isSSHConnected , setIsSSHConnected ] = useState ( false ) ;
2727 const [ isSSHDisconnecting , setIsSSHDisconnecting ] = useState ( false ) ;
28+ const [ isDetaching , setIsDetaching ] = useState ( false ) ;
2829
2930 const handleKeyDown = ( e ) => {
3031
@@ -97,19 +98,49 @@ function Terminal() {
9798 } , interval * 6 ) ;
9899 }
99100
100- if ( ! isSSHDisconnecting && cmd === "" ) {
101- setHistory ( prev => response ? [ ...prev , newEntry , response ] : [ ...prev , newEntry ] ) ;
102- return ;
101+ const runAnimation = ( text , interval , final_text , startTime ) => {
102+
103+ setTimeout ( ( ) => {
104+ setHistory ( prev => [ ...prev , { type : 'output' , content : text } ] ) ;
105+ } , startTime ) ;
106+
107+ [ 1 , 2 , 3 ] . forEach ( dotCount => {
108+ setTimeout ( ( ) => {
109+ setHistory ( prev => {
110+ const newHistory = [ ...prev ] ;
111+ const lastIndex = newHistory . length - 1 ;
112+ newHistory [ lastIndex ] = {
113+ ...newHistory [ lastIndex ] ,
114+ content : `${ text } ${ '.' . repeat ( dotCount ) } `
115+ } ;
116+ return newHistory ;
117+ } ) ;
118+ } , startTime + ( interval * dotCount ) ) ;
119+ } ) ;
120+
121+ setTimeout ( ( ) => {
122+ setHistory ( prev => {
123+ const newHistory = [ ...prev ] ;
124+ const lastIndex = newHistory . length - 1 ;
125+ newHistory [ lastIndex ] = { ...newHistory [ lastIndex ] , content : final_text } ;
126+ return newHistory ;
127+ } ) ;
128+ } , startTime + ( interval * 4 ) ) ;
129+ } ;
130+
131+ if ( cmd === "" ) {
132+ if ( ! isSSHDisconnecting && ! isDetaching ) {
133+ setHistory ( prev => response ? [ ...prev , newEntry , response ] : [ ...prev , newEntry ] ) ;
134+ return ;
135+ }
103136 }
104137
105138 if ( cmd === "loader" ) {
106139 loader ( "Loading" , 750 , "Loaded!" ) ;
107140 return ;
108141 }
109142
110- const DISCONNECT_ABORT_MSG = `MISSION ABORT HELL YEAH\n `
111-
112- if ( isSSHDisconnecting ) {
143+ if ( isSSH && isSSHConnected && isSSHDisconnecting ) {
113144 if ( cmd === "yes" || cmd === "y" ) {
114145 setIsSSH ( false ) ;
115146 setIsSSHConnected ( false ) ;
@@ -121,7 +152,7 @@ function Terminal() {
121152
122153 setPrompt ( DEFAULT_PROMPT ) ;
123154 setHistory ( prev => [ ...prev , asyncResponse ] ) ;
124- } , 750 * 6 ) ;
155+ } , 500 * 6 ) ;
125156 return ;
126157 }
127158 else if ( cmd === "no" || cmd === "n" || cmd === "" ) {
@@ -137,7 +168,49 @@ function Terminal() {
137168 // setPrompt(SSH_PROMPT);
138169 return ;
139170 }
171+ }
172+
173+ else if ( isSSH && isSSHConnected && isDetaching ) {
174+ if ( cmd === "yes" || cmd === "y" ) {
175+ setInput ( "" ) ;
176+ setPrompt ( "" ) ;
140177
178+ setIsSSHDisconnecting ( false ) ;
179+ setIsSSHConnected ( false ) ;
180+ setIsSSH ( false ) ;
181+ setIsDetaching ( false ) ;
182+
183+ runAnimation ( "TODO" , 600 , "Attempting to revoke device control... ALLOWED." , 0 ) ;
184+
185+ // runAnimation("Establishing secure shell", 750, "Connected to Kali node.", 400 * 5);
186+
187+ setTimeout ( ( ) => {
188+ const welcomeMsg = {
189+ type : 'output' ,
190+ content :
191+ `\nUhm wattesigma.\n` +
192+ `HOLD UP I WILL MAKE THIS.\n\n`
193+ } ;
194+ setHistory ( prev => [ ...prev , welcomeMsg ] ) ;
195+ setPrompt ( DEFAULT_PROMPT ) ;
196+ } , 600 * 5 ) ;
197+
198+ return ;
199+ }
200+ else if ( cmd === "no" || cmd === "n" || cmd === "" ) {
201+ setIsSSH ( true ) ;
202+ setIsSSHConnected ( true ) ;
203+ setIsSSHDisconnecting ( false ) ;
204+ setIsDetaching ( false ) ;
205+
206+ response = { type : 'output' , content : "\n" } ;
207+ setPrompt ( SSH_PROMPT ) ;
208+ }
209+ else {
210+ // response = { type: 'output', content: DISCONNECT_ABORT_MSG };
211+ // setPrompt(SSH_PROMPT);
212+ return ;
213+ }
141214 }
142215
143216 else if ( isSSH && isSSHConnected ) {
@@ -161,12 +234,33 @@ function Terminal() {
161234
162235 else if ( cmd . startsWith ( "detach" ) ) {
163236 if ( cmd === "detach 1" ) {
164- response = { type : 'output' , content : `WIP PLEASE STAND BY-\n ` } ;
237+ setHistory ( prev => [ ...prev , newEntry ] ) ;
238+ setPrompt ( "" ) ;
239+ setInput ( "" ) ;
240+
241+ runAnimation ( "Attempting to revoke device control" , 600 , "Attempting to revoke device control... ALLOWED." , 0 ) ;
242+
243+ // runAnimation("Establishing secure shell", 750, "Connected to Kali node.", 400 * 5);
244+
245+ setTimeout ( ( ) => {
246+ const welcomeMsg = {
247+ type : 'output' ,
248+ content :
249+ `\nWARNING: Device 1 is the primary control node.\n` +
250+ `Detaching will terminate attacker's session.\n\n`
251+ } ;
252+ setHistory ( prev => [ ...prev , welcomeMsg ] ) ;
253+ setPrompt ( "Proceed? (y/N): " ) ;
254+ } , 600 * 5 ) ;
255+
256+ setIsDetaching ( true ) ;
257+ setIsSSHDisconnecting ( false ) ;
258+
259+ return ;
165260 }
166261 else {
167262 response = { type : 'error' , content : `Permission denied.\nDevice protected by administrator\n ` } ;
168263 }
169-
170264 }
171265
172266 else if ( SSH_COMMANDS [ cmd ] ) {
@@ -179,42 +273,12 @@ function Terminal() {
179273 }
180274 }
181275
182- else if ( isSSH ) {
276+ else if ( isSSH && ! isSSHConnected ) {
183277 if ( cmd === sshPassword ) {
184278 setHistory ( prev => [ ...prev , newEntry ] ) ;
185279 setPrompt ( "" ) ;
186280 setInput ( "" ) ;
187281
188- const runAnimation = ( text , interval , final_text , startTime ) => {
189-
190- setTimeout ( ( ) => {
191- setHistory ( prev => [ ...prev , { type : 'output' , content : text } ] ) ;
192- } , startTime ) ;
193-
194- [ 1 , 2 , 3 ] . forEach ( dotCount => {
195- setTimeout ( ( ) => {
196- setHistory ( prev => {
197- const newHistory = [ ...prev ] ;
198- const lastIndex = newHistory . length - 1 ;
199- newHistory [ lastIndex ] = {
200- ...newHistory [ lastIndex ] ,
201- content : `${ text } ${ '.' . repeat ( dotCount ) } `
202- } ;
203- return newHistory ;
204- } ) ;
205- } , startTime + ( interval * dotCount ) ) ;
206- } ) ;
207-
208- setTimeout ( ( ) => {
209- setHistory ( prev => {
210- const newHistory = [ ...prev ] ;
211- const lastIndex = newHistory . length - 1 ;
212- newHistory [ lastIndex ] = { ...newHistory [ lastIndex ] , content : final_text } ;
213- return newHistory ;
214- } ) ;
215- } , startTime + ( interval * 4 ) ) ;
216- } ;
217-
218282 runAnimation ( "Validating connection" , 750 , "IP accepted." , 0 ) ;
219283
220284 runAnimation ( "Establishing secure shell" , 750 , "Connected to Kali node." , 750 * 5 ) ;
@@ -289,6 +353,7 @@ function Terminal() {
289353 response = { type : 'error' , content : `'${ cmd } ' is not recognized as an internal or external command, \noperable program or batch file.\n ` } ;
290354 }
291355 }
356+
292357 setHistory ( prev => response ? [ ...prev , newEntry , response ] : [ ...prev , newEntry ] ) ;
293358 }
294359 } ;
0 commit comments