从 C# 应用程序登录到 joomla

login to joomla from a c# application(从 C# 应用程序登录到 joomla)
本文介绍了从 C# 应用程序登录到 joomla的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

问题描述

我也使用多种方法登录到 joomla 管理面板.但返回值与登录页面相同.即使用户名和密码正确.

i use many methods too login in to joomla admin panel. but the returned value is same az the login page. even when the username and password are correct.

示例:

WebClient Client = new WebClient();
System.Collections.Specialized.NameValueCollection Collection = 
    new System.Collections.Specialized.NameValueCollection();
Collection.Add("username", "--my username--");
Collection.Add("passwd", "--my password--");
Collection.Add("option", "com_login");
Colletion.Add("e0484cdc56d8ccc42187d26a813324ba", "1");
Collection.Add("lang", "");

Client.Proxy = null;
byte[] res = Client.UploadValues(
    "http://127.0.0.1/administrator/index.php", "POST", Collection);
textBox1.Text = Encoding.UTF8.GetString(res, 0, res.Length);

推荐答案

问题出在这一行:

Colletion.Add("e0484cdc56d8ccc42187d26a813324ba", "1");

这是 joomla 的 CSRF 反欺骗令牌.乔姆拉!尝试通过在每个 POST 表单和每个 GET 查询字符串中插入一个 this 令牌来保护 CSRF,这些字符串可以修改 Joomla! 中的某些内容!系统.这个随机字符串提供了保护,因为受感染的站点不仅需要知道目标站点的 URL 和目标站点的有效请求格式,还必须知道随每个会话和每个用户而变化的随机字符串.

which is joomla's CSRF anti-spoofing token. Joomla! attempts to protect againt CSRF by inserting a this token into each POST form and each GET query string that is able to modify something in the Joomla! system. This random string provides protection because not only does the compromised site need to know the URL of the target site and a valid request format for the target site, it also must know the random string which changes for each session and each user.

为了在您的登录请求中发送正确的令牌,您必须:

In order to sent a correct token with your login request you'd have to:

  1. 首先使用客户端对象"请求通过 GET 请求正确的登录表单
  2. 使用正则表达式检索令牌 /name="([a-zA-z0-9]{32})"/
  3. 使用令牌发送登录请求

祝你好运

在您的集合"中再添加一个参数:

To your "collection" add one more param:

Collection.Add("task", "login");

这篇关于从 C# 应用程序登录到 joomla的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

本站部分内容来源互联网,如果有图片或者内容侵犯了您的权益,请联系我们,我们会在确认后第一时间进行删除!

相关文档推荐

Multicast delegate weird behavior in C#?(C# 中的多播委托奇怪行为?)
Parameter count mismatch with Invoke?(参数计数与调用不匹配?)
How to store delegates in a List(如何将代表存储在列表中)
How delegates work (in the background)?(代表如何工作(在后台)?)
C# Asynchronous call without EndInvoke?(没有 EndInvoke 的 C# 异步调用?)
Delegate.CreateDelegate() and generics: Error binding to target method(Delegate.CreateDelegate() 和泛型:错误绑定到目标方法)