douzhi2012 2019-01-18 21:00
浏览 630

如何在源代码中隐藏POST请求中使用的参数?

I'm wanting to send variables to a waiting PHP document using the POST method, but these variables are used as arguments to do things such as delete, hide, etc.

The problem is that I only know of two ways to do this:

  1. An href attribute where you build your URL
  2. Using an XMLHttpRequest

There is a security risk with both of these methods as they will show the variables within the source code. This could lead to someone having control over other user's data through manipulation of the URL. All they would need is the readily available variable and the user name.

function usrVisToggle(){
    var adjNum = Number(document.getElementById('lineNum').value);
    var adjSend = new XMLHttpRequest();
    adjSend.open('POST', 'https://000webhostapp.com');
    adjSend.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
    adjSend.send('argument=4&adjusted=' + adjNum, false);
    location.reload();

The above is an example of how my code works right now.

The problem is within the argument=4. This will show in the source code and once you get the argument you can begin toggling everyones' data to be visible/invisible. Building your own URL to use in HTML poses the same risk.

What would be some ways around this?

  • 写回答

2条回答 默认 最新

  • 普通网友 2019-01-18 21:07
    关注

    Not two minutes after this post I realized that instead of focusing on the manipulation codes, I could just make an impossibly hard to guess user code and save to database. This renders the argument=4 almost moot because you would have to break into the database to steal the information, or get lucky and guess a really long string that relates to the user.

    评论

报告相同问题?

悬赏问题

  • ¥15 按键修改电子时钟,C51单片机
  • ¥60 Java中实现如何实现张量类,并用于图像处理(不运用其他科学计算库和图像处理库))
  • ¥20 5037端口被adb自己占了
  • ¥15 python:excel数据写入多个对应word文档
  • ¥60 全一数分解素因子和素数循环节位数
  • ¥15 ffmpeg如何安装到虚拟环境
  • ¥188 寻找能做王者评分提取的
  • ¥15 matlab用simulink求解一个二阶微分方程,要求截图
  • ¥30 乘子法解约束最优化问题的matlab代码文件,最好有matlab代码文件
  • ¥15 写论文,需要数据支撑