login to joomla from a c# application(从 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:
- 首先使用客户端对象"请求通过 GET 请求正确的登录表单
- 使用正则表达式检索令牌
/name="([a-zA-z0-9]{32})"/ - 使用令牌发送登录请求
祝你好运
在您的集合"中再添加一个参数:
To your "collection" add one more param:
Collection.Add("task", "login");
这篇关于从 C# 应用程序登录到 joomla的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:从 C# 应用程序登录到 joomla
基础教程推荐
- 在 VS2010 中的 Post Build 事件中将 bin 文件复制到物 2022-01-01
- 经典 Asp 中的 ResolveUrl/Url.Content 等效项 2022-01-01
- 错误“此流不支持搜索操作"在 C# 中 2022-01-01
- JSON.NET 中基于属性的类型解析 2022-01-01
- 将事件 TextChanged 分配给表单中的所有文本框 2022-01-01
- 首先创建代码,多对多,关联表中的附加字段 2022-01-01
- 是否可以在 asp classic 和 asp.net 之间共享会话状态 2022-01-01
- 如何动态获取文本框中datagridview列的总和 2022-01-01
- 从 VS 2017 .NET Core 项目的发布目录中排除文件 2022-01-01
- 全局 ASAX - 获取服务器名称 2022-01-01
