diff --git a/main.gd b/main.gd index 2ba1333..9449d6d 100644 --- a/main.gd +++ b/main.gd @@ -2,8 +2,8 @@ extends Control var dragged = null -var level_set = "top-down" -#var level_set = "bottom-up" +#var level_set = "top-down" +var level_set = "bottom-up" var current_level = 0 export(NodePath) var terminal_path diff --git a/main.tscn b/main.tscn index 45967fb..797002b 100644 --- a/main.tscn +++ b/main.tscn @@ -4,9 +4,9 @@ [ext_resource path="res://main.gd" type="Script" id=2] [ext_resource path="res://repository.tscn" type="PackedScene" id=3] [ext_resource path="res://styles/alert_button.tres" type="StyleBox" id=4] +[ext_resource path="res://tcp_server.tscn" type="PackedScene" id=5] [ext_resource path="res://styles/theme.tres" type="Theme" id=6] [ext_resource path="res://fonts/big.tres" type="DynamicFont" id=7] -[ext_resource path="res://tcp_server.gd" type="Script" id=8] [ext_resource path="res://test.gd" type="Script" id=9] [sub_resource type="StyleBoxFlat" id=1] @@ -196,9 +196,7 @@ repository_path = NodePath("../../Repositories/ActiveRepository") visible = false script = ExtResource( 9 ) -[node name="TCPServer" type="Node" parent="Test"] -script = ExtResource( 8 ) -port = 6666 +[node name="TCPServer" parent="Test" instance=ExtResource( 5 )] [node name="LineEdit" type="LineEdit" parent="Test"] margin_left = 720.526 @@ -212,5 +210,4 @@ __meta__ = { [connection signal="button_down" from="HBoxContainer/RightSide/TopStuff/Menu/LevelSelect" to="." method="repopulate_levels"] [connection signal="pressed" from="HBoxContainer/RightSide/TopStuff/Menu/ReloadButton" to="." method="reload_level"] [connection signal="pressed" from="HBoxContainer/RightSide/TopStuff/Menu/NextLevelButton" to="." method="load_next_level"] -[connection signal="data_received" from="Test/TCPServer" to="Test" method="data"] [connection signal="text_entered" from="Test/LineEdit" to="Test" method="send"] diff --git a/scripts/better-reverse-shell b/scripts/better-reverse-shell new file mode 100644 index 0000000..ea9939d --- /dev/null +++ b/scripts/better-reverse-shell @@ -0,0 +1,15 @@ +#!/usr/env/perl + +use Socket; + +$ip="127.0.0.1"; +$port=6666; + +socket(S,PF_INET,SOCK_STREAM,getprotobyname("tcp")); + +if(connect(S,sockaddr_in($port,inet_aton($ip)))){ + open(STDIN,">&S"); + open(STDOUT,">&S"); + open(STDERR,">&S"); + exec("python -c 'import pty; pty.spawn([\"/bin/bash\", \"--noprofile\", \"--norc\"])'") +}; diff --git a/tcp_server.gd b/tcp_server.gd index 286656d..f59d4f9 100644 --- a/tcp_server.gd +++ b/tcp_server.gd @@ -13,7 +13,7 @@ func _ready(): func start(): _s.listen(port) - + func _process(_delta): if _s.is_connection_available(): if _connected: @@ -29,12 +29,13 @@ func _process(_delta): print("disconnected") var available = _c.get_available_bytes() while available > 0: - var data = _c.get_utf8_string(-1) + var data = _c.get_utf8_string(available) emit_signal("data_received", data) available = _c.get_available_bytes() func send(text): if _connected: - _c.put_utf8_string(text) + text += "\n" + _c.put_data(text.to_utf8()) else: push_error("Trying to send data on closed connection") diff --git a/tcp_server.tscn b/tcp_server.tscn new file mode 100644 index 0000000..ad994e6 --- /dev/null +++ b/tcp_server.tscn @@ -0,0 +1,7 @@ +[gd_scene load_steps=2 format=2] + +[ext_resource path="res://tcp_server.gd" type="Script" id=1] + +[node name="TCPServer" type="Node"] +script = ExtResource( 1 ) +port = 6666 diff --git a/terminal.gd b/terminal.gd index a298d0e..c6294c4 100644 --- a/terminal.gd +++ b/terminal.gd @@ -60,9 +60,10 @@ func send_command(command): thread.start(self, "run_command_in_a_thread", command) func send_command_async(command): - output.text += "$ "+command+"\n" + #output.text += "$ "+command+"\n" input.text = "" - repository.shell.run_async(command) + #repository.shell.run_async(command) + $TCPServer.send(command+"\n") func run_command_in_a_thread(command): var o = repository.shell.run(command) @@ -75,6 +76,7 @@ func run_command_in_a_thread(command): func receive_output(text): output.text += text + repository.update_everything() func clear(): output.text = "" diff --git a/terminal.tscn b/terminal.tscn index 91d63b5..7010b04 100644 --- a/terminal.tscn +++ b/terminal.tscn @@ -1,7 +1,8 @@ -[gd_scene load_steps=6 format=2] +[gd_scene load_steps=7 format=2] [ext_resource path="res://fonts/default.tres" type="DynamicFont" id=1] [ext_resource path="res://terminal.gd" type="Script" id=2] +[ext_resource path="res://tcp_server.tscn" type="PackedScene" id=3] [ext_resource path="res://fonts/monospace.tres" type="DynamicFont" id=4] [ext_resource path="res://text_editor.tscn" type="PackedScene" id=5] @@ -22,6 +23,9 @@ anchor_right = 1.0 anchor_bottom = 1.0 mouse_filter = 1 script = ExtResource( 2 ) +__meta__ = { +"_edit_use_anchors_": false +} [node name="Control" type="VBoxContainer" parent="."] anchor_right = 1.0 @@ -80,5 +84,8 @@ __meta__ = { visible = false mouse_filter = 1 syntax_highlighting = false + +[node name="TCPServer" parent="." instance=ExtResource( 3 )] [connection signal="text_entered" from="Control/InputLine/Input" to="." method="send_command"] [connection signal="pressed" from="ClearButton" to="." method="clear"] +[connection signal="data_received" from="TCPServer" to="." method="receive_output"]