Files
huishou/find-redirect.mjs
2026-07-27 14:07:26 +08:00

56 lines
1.4 KiB
JavaScript

import { Client } from 'ssh2';
const conn = new Client();
conn.on('ready', () => {
console.log('=== 查找重定向规则 ===\n');
conn.exec('grep -r "admin" /www/server/panel/vhost/nginx/hs.yifenbao.cn.conf', (err, stream) => {
if (err) {
console.log('搜索失败:', err.message);
} else {
stream.on('data', (data) => {
console.log('admin相关:', data.toString());
});
}
stream.on('close', () => {
conn.exec('curl -s -I https://hs.yifenbao.cn/', (err, stream2) => {
if (err) {
console.log('响应头失败:', err.message);
} else {
stream2.on('data', (data2) => {
console.log('\n根路径响应头:', data2.toString());
});
}
stream2.on('close', () => {
conn.exec('curl -s -I https://hs.yifenbao.cn/index.html', (err, stream3) => {
if (err) {
console.log('HTML响应头失败:', err.message);
} else {
stream3.on('data', (data3) => {
console.log('\nindex.html响应头:', data3.toString());
});
}
stream3.on('close', () => {
conn.end();
});
});
});
});
});
});
});
conn.on('error', (err) => {
console.log('连接错误:', err.message);
});
conn.connect({
host: 'hs.yifenbao.cn',
port: 22,
username: 'root',
password: 'Torch1112'
});