searchusermenu
  • 发布文章
  • 消息中心
点赞
收藏
评论
分享
原创

通过网页共享终端输出

2023-08-24 02:39:47
3
0

一,fiche 安装

可以通过官方提供的服务使用fiche,但为了信息安全不建议这么做。
从github下载fiche代码,

2.1 编译安装

$ cd fiche
$ make
$ sudo make install

2.2 源码定制

可以修改源码,将最新内容输出到0000页面,将log输出到ffff页面。

diff --git a/fiche.c b/fiche.c
index 99d140d..3597242 100644
--- a/fiche.c
+++ b/fiche.c
@@ -462,6 +462,10 @@ static int start_server(Fiche_Settings *settings) {
     print_status("Server started listening on: %s:%d.",
 		    settings->listen_addr, settings->port);
     print_separator();
+    if(create_directory(settings->output_dir_path, "0000") != 0 || 
+            create_directory(settings->output_dir_path, "ffff") != 0) {
+        print_error("Create directory error!");
+    }
 
     // Run dispatching loop
     while (1) {
@@ -640,7 +644,8 @@ static void *handle_connection(void *args) {
 
 
     // Save to file failed, we have to finish here
-    if ( save_to_file(c->settings, buffer, slug) != 0 ) {
+    if ((save_to_file(c->settings, buffer, "0000") != 0) 
+        || (save_to_file(c->settings, buffer, slug) != 0)) {
         print_error("Couldn't save a file!");
         print_separator();

2.3 设置系统服务并启动

``

$ sudo vim /lib/systemd/system/fiche.service
[Unit]
Description=FICHE-SERVER

[Service]
ExecStart=/usr/local/bin/fiche -d your.ip:9998 -o /var/www/fiche -l /var/www/fiche/ffff/index.txt -u root -B 6553600

[Install]
WantedBy=multi-user.target

$ sudo systemctl daemon-reload
$ sudo systemctl enable fiche
$ sudo systemctl restart fiche
$ alias tb="nc localhost 9999"

二,nginx安装

可以配置成本地ip或者公网ip和指定端口

$ sudo apt install nginx
$ vim /etc/nginx/sites-enabled/fiche 
server {
    listen 9998;
    server_name your.ip:9998;
    charset utf-8;

    location / {
            root /var/www/fiche/;
            index index.txt index.html;
    }
}
$ sudo systemctl restart nginx

三, 使用

可以将nc或者curl命令将终端输出内容上传到fiche服务, 会返回一个http地址,可以通过网页或者curl命令直接查看内容。

$ dmesg | nc localhost 9999
$ dmesg | curl --data-binary @- localhost:9999
上传剪切板内容
$ xclip -o | nc localhost 9999
0条评论
0 / 1000