n/haoduoshuiu/guguan123 · 5 个月前
注册 登录
n/haoduoshui · 5 个月前 · 已编辑 · 401 次浏览
u/guguan123铂金

【水】简单复刻了全站最无聊的动态网站

忘记了是什么时候在论坛刷到一个号称最无聊的网站的帖子,就是一个计数器每次访问就+1,
但是看起来还是有点太复杂了,就复刻了一个简化版本:

https://cat.com.cfd/cgi-bin/counter.cgi

也是非常的简单无聊,估计各位闭着眼都能想到怎么写了,但是我还是把源码贴出来把帖子水长一点

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <errno.h>

#define COUN_FILE "../counter.txt"

int main() {
	FILE *file;
	int count = 0;

	file = fopen(COUN_FILE, "r+");
	if (file == NULL) {
		printf("Status: 500 Internal Server Error\r\nContent-Type: text/plain; charset=utf-8\r\n\r\n");
		printf("Error: Cannot open %s (%s)\r\n", COUN_FILE, strerror(errno));
		return 1;
	}
	fscanf(file, "%d", &count);
	count++;
	rewind(file);
	fprintf(file, "%d", count);
	fclose(file);
	printf("Content-Type: text/plain; charset=utf-8\r\n\r\n%d\r\n", count);

	return 0;
}
5
12
登录后参与讨论。

12 条回复

排序
  1. Serendipity1 钻石 5 个月前

    感谢大佬分享

    1
  2. ASCG 钻石 5 个月前

    看不懂

    0
  3. Struhaqi 黄金 5 个月前

    :xhj001:

    0
  4. azhaoyihao 荣耀 水王 5 个月前

    这也太无聊了吧

    0
  5. w-d 钻石 5 个月前

    无聊的东西有时也是一种点缀

    0
  6. BigDick 铂金 文圣 5 个月前 已编辑

    啊?这个也能被挂马?

    图片
    0
  7. guguan123 铂金 楼主 5 个月前

    咋可能?这玩意甚至都不是响应的HTML,就只是一个数字

    0
  8. guguan123 铂金 楼主 5 个月前

    可能是 com.cfd 的邻居被挂马了?

    0
  9. BigDick 铂金 文圣 5 个月前

    不清楚 但是确实被提示了
    处理一下吧 要不然域名被污染了

    0
  10. guguan123 铂金 楼主 5 个月前

    应该是域名的问题,这种简单至极的网站根本没地方给挂马😂

    lxd11451432350:/var/tmp/www/htdocs# tree
    .
    ├── busybox_HTTPD
    ├── cgi-bin
    │   ├── __down.cgi
    │   ├── counter.cgi
    │   └── info.cgi
    ├── counter.txt
    ├── index.html
    └── my_app.rar
    
    1 directories, 7 files
    

    更何况是直接用nobody用户运行的httpd,没有权限更改任何内容

    0
  11. 继续这个对话 →
  12. person 白银 5 个月前

    看不懂

    0