PDA

View Full Version : سوال: مشكل با رمزنگاري كانكشن استرينگ



sav68.net
جمعه 27 شهریور 1388, 00:58 صبح
سلام دوستان

من به تازگي يك وبسايت آپلود كردم كه كانكشن استرينكش رو رمز نگاري كردم
يكبار با DataProtectionConfigurationProvider
و يكبار هم با RsaProtectedConfigurationProvider پروايدرها اما هر دو دفعه از من خطا گرفت
خطاي مربرط به پروايدر دومي رو ميذارم



Server Error in '/' Application.

Configuration Error

Description: An error occurred during the processing of a configuration file required to service this request. Please review the specific error details below and modify your configuration file appropriately.

Parser Error Message: Failed to decrypt using provider 'RsaProtectedConfigurationProvider'. Error message from the provider: The RSA key container could not be opened.

Source Error:

Line 1: <connectionStrings configProtectionProvider="RsaProtectedConfigurationProvider">
Line 2: <EncryptedData Type="http://www.w3.org/2001/04/xmlenC#‎Element"
Line 3: xmlns="http://www.w3.org/2001/04/xmlenC#‎">
Line 4: <EncryptionMethod Algorithm="http://www.w3.org/2001/04/xmlenC#‎tripledes-cbc" />
Source File: C:\Inetpub\whosts\iran....com\httpdocs\Connection. Config Line: 2

Version Information: Microsoft .NET Framework Version:2.0.50727.3082; ASP.NET Version:2.0.50727.3082

چكار كنم درست شه؟

با تشكر

sav68.net
جمعه 27 شهریور 1388, 21:50 عصر
دوستان لطفا كمك كنيد

امنيت برنامم در خطر
فكر كنم تا الان 40 50 نفر رفتن و پسورد ديتابيس رو برداشتن

صابر
شنبه 28 شهریور 1388, 02:46 صبح
سلام،
من از این دو متد استفاده می‌کنم و مشکلی ندارم:

public static string ProtectSection(string sectionName)
{
Configuration config = System.Web.Configuration.WebConfigurationManager.
OpenWebConfiguration(HttpContext.Current.Request.A pplicationPath);

ConfigurationSection section = config.GetSection(sectionName);
if (section != null && !section.SectionInformation.IsProtected)
{
section.SectionInformation.ProtectSection("DataProtectionConfigurationProvider");
config.Save();
return section.SectionInformation.IsProtected ? "Protected" : "Unprotected";
}
return "section not found.";
}
public static string UnProtectSection(string sectionName)
{
Configuration config = System.Web.Configuration.WebConfigurationManager.
OpenWebConfiguration(HttpContext.Current.Request.A pplicationPath);

ConfigurationSection section = config.GetSection(sectionName);
if (section != null && section.SectionInformation.IsProtected)
{
section.SectionInformation.UnprotectSection();
config.Save();
return section.SectionInformation.IsProtected ? "Protected" : "Unprotected";
}
return "section not found.";
}

atbin2010
سه شنبه 07 مهر 1388, 07:54 صبح
سلام
این فانکشن ها رو کجا باید بنویسیم؟
ممنونم

RoostaYeBekr
سه شنبه 07 مهر 1388, 16:19 عصر
بچه ها ، یکی توی همین تاپیک می گه چطوری می شه کانکشن استرینگی که رمزگذاری نشده ، هک کرد ؟

فقط جون هر کی می پرستید ، از این حرف ها نزنید که هک خیلی کار زشتیه و توی این سایت نباید راجع بهش بحث بشه .

ماها ناسلامتی می خوایم تو برنامه نویسی پیشرفت کنیم . پس هم باید بدونیم که دیگران چطوری هکمون می کنند و هم راه حلش رو بدونیم تا هک نشیم .

صابر
سه شنبه 07 مهر 1388, 16:46 عصر
سلام
این فانکشن ها رو کجا باید بنویسیم؟
ممنونم
فرق نمی‌کنه، کافیه فقط یک بار متد ProtectSection صدا زده بشه.
UnProtectSection هم برای اینه که اگه زمانی Connection String روخواستین از حالت protect شده در بیارین اونو یک بار call کنید.

sav68.net
جمعه 10 مهر 1388, 17:22 عصر
سلام

آقا صابر مشكل من حل نشد

اگر فايل web.config رو لوكال رمزگذاري كنم و بعد آپلودش كنم كه پيام زير رو ميده


Configuration Error

Description: An error occurred during the processing of a configuration file required to service this request. Please review the specific error details below and modify your configuration file appropriately.

Parser Error Message: Failed to decrypt using provider 'DataProtectionConfigurationProvider'. Error message from the provider: Key not valid for use in specified state. (Exception from HRESULT: 0x8009000B)

Source Error:

Line 1: <connectionStrings configProtectionProvider="DataProtectionConfigurationProvider">
Line 2: <EncryptedData>
Line 3: <CipherData>
Line 4: <CipherValue
.
.
.



اگر هم كه آنلاين بخوام رمزكذاري كنم پيام زير رو ميده :


Configuration Error

Description: An error occurred during the processing of a configuration file required to service this request. Please review the specific error details below and modify your configuration file appropriately.

Parser Error Message: An error occurred loading a configuration file: Access to the path 'C:\Inetpub\whosts\iran....com\httpdocs\jslp1lw4.t mp' is denied.

Source Error:

[No relevant source lines]
Source File: C:\Inetpub\whosts\iran....com\httpdocs\web.config Line: 0

لطفا راهنمايي كنيد

خيلي فوري است

صابر
جمعه 10 مهر 1388, 17:57 عصر
این روش machine specific هست، یعنی باید روی خود سیستم عاملی انجام بگیره که وب‌سرور اونجا هست.
نمی‌شه از توی کامپیوتر خودتون encrypt کنید و بعد روی server از اون استفاده کنید.

در مورد error دوم، به دلیل دسترسی هست. ما چون روی dedicated server این کار رو کردیم این مشکل رو نداشتیم.
Search کردم و دیدم چند forum نوشته به جای ConfigurationSection از ConnectionStringSettings استفاده کنید.

ConnectionStringSettings _connectionStrings = System.Web.Configuration.WebConfigurationManager.C onnectionStrings[connectionstringname];

sav68.net
جمعه 10 مهر 1388, 20:06 عصر
ممنون كه جواب دادين

چك ميكنم اگه بازم مشكلي بود مزاحمتون ميشم:چشمک:

sav68.net
جمعه 10 مهر 1388, 22:23 عصر
سلام

آقا من كدها رو بصورت زير تغيير دادم


public static string ProtectSection(string sectionName)
{
Configuration config = System.Web.Configuration.WebConfigurationManager.
OpenWebConfiguration(HttpContext.Current.Request.A pplicationPath);

ConnectionStringSettings _connectionStrings =
System.Web.Configuration.WebConfigurationManager.C onnectionStrings[sectionName];

if (_connectionStrings != null && !_connectionStrings.SectionInformation.IsProtected )
{
_connectionStrings.SectionInformation.ProtectSecti on("DataProtectionConfigurationProvider");
config.Save();
return _connectionStrings.SectionInformation.IsProtected ? "Protected" : "Unprotected";
}
return "section not found.";
}



اما حالا خطاي زير رو ميده


Compilation Error

Description: An error occurred during the compilation of a resource required to service this request. Please review the following specific error details and modify your source code appropriately.

Compiler Error Message: CS0117: 'System.Configuration.ConnectionStringSettings' does not contain a definition for 'SectionInformation'

Source Error:


Line 118: System.Web.Configuration.WebConfigurationManager.C onnectionStrings[sectionName];
Line 119:
Line 120: if (_connectionStrings != null && !_connectionStrings.SectionInformation.IsProtected )
Line 121: {
Line 122: _connectionStrings.SectionInformation.ProtectSecti on("DataProtectionConfigurationProvider");
Source File: f:\4 write\project\Iran...\Iran...SQLmemberShip\Secure\ Manage\SecurityConfig\Encryption.aspx.cs Line: 120


لطفا بازم راهنمايي كن
ان شالله يك در دنيا و 100 در آخرت

sav68.net
شنبه 11 مهر 1388, 15:38 عصر
دوستان لطفا اگه كسي قبلا با اين مشكل روبرو شده كمك كنه
.
.
يعني هيچ كس تا حالا كانكشن استرينگ رو توي هاست رمز گذاري نكرده؟

sav68.net
شنبه 11 مهر 1388, 23:55 عصر
هم اكنون نيازمند ياري سبزتان هستيم








انجمن ...

SabaSabouhi
یک شنبه 12 مهر 1388, 10:36 صبح
دوستان لطفا اگه كسي قبلا با اين مشكل روبرو شده كمك كنه
.
.
يعني هيچ كس تا حالا كانكشن استرينگ رو توي هاست رمز گذاري نكرده؟

با سلام
من هم سعی کردم و موفق نشدم. یه تاپیک تو همین تالار زدم که جواب نگرفتم. روش کارم ظاهراً اشکالی نداره ( همه جا همین روش رو گفتن ). اما گمان می‌کنم اشکال از دسترسی فایل web.config باشه. هر چند که با control panel سایت هر چی دسترسی بود رو بهش دادم.

صبا صبوحی

eyes_shut_number1
یک شنبه 12 مهر 1388, 18:18 عصر
sectionName چی هستش؟ باید چی براش پاس بشه؟
و این که کجا باید این کار رو کرد؟ فقط یک بار باید بشه!؟


سلام،
من از این دو متد استفاده می‌کنم و مشکلی ندارم:

public static string ProtectSection(string sectionName)
{
Configuration config = System.Web.Configuration.WebConfigurationManager.
OpenWebConfiguration(HttpContext.Current.Request.A pplicationPath);

ConfigurationSection section = config.GetSection(sectionName);
if (section != null && !section.SectionInformation.IsProtected)
{
section.SectionInformation.ProtectSection("DataProtectionConfigurationProvider");
config.Save();
return section.SectionInformation.IsProtected ? "Protected" : "Unprotected";
}
return "section not found.";
}
public static string UnProtectSection(string sectionName)
{
Configuration config = System.Web.Configuration.WebConfigurationManager.
OpenWebConfiguration(HttpContext.Current.Request.A pplicationPath);

ConfigurationSection section = config.GetSection(sectionName);
if (section != null && section.SectionInformation.IsProtected)
{
section.SectionInformation.UnprotectSection();
config.Save();
return section.SectionInformation.IsProtected ? "Protected" : "Unprotected";
}
return "section not found.";
}

صابر
یک شنبه 12 مهر 1388, 18:43 عصر
یک Page درست کنید (ترجیحاً password داشته باشد)،
یک دکمه به اسم Protect و یک دکمه به اسم UnProtect در آن صفحه بگذارید.
و رویداد کلیک را به این صورت بنویسید:

Response.Write(ProtectSection("connectionStrings"));
بعد از upload کافی‌ست یک بار دکمه Protect را بزنید.

البته مثل اینکه دوستان مشکل دسترسی داشتن.. ما روی dedicated server خودمان این کار را کردیم و مشکلی نداریم.