My first question is that the 'debugger' and function list for cobra created for Notepad++ doesn't work, I can get the syntax to work, but every time I try adding the files to the appropriate location, notepad++ comes up with a very vague window that just keeps popping up saying error. Could this be because I didn't actually properly install notepad?
The second is that the command line (or cmd.exe) keeps saying that 'cobra' isn't a command, I did install cobra properly, but has something like this come up before? Or is it just me and I should try re installing it?
The third is that I need some serious help with converting some C# code to Cobra. What this thing is going to be used for is to make a bot for a chat at deviantart.com, there is help for this sort of thing there, but not for Cobra language, this specific script does is it Grabs a Cookie on the deviantart login screen because it will need that to be allowed into the chat. Now what I actually did was use a converter to convert VB.NET to C# so the source code itself may contain errors but here is the source:
- Code: Select all
using Microsoft.VisualBasic;
using System;
using System.Collections;
using System.Collections.Generic;
using System.Data;
using System.Diagnostics;
using System.web;
using System.Threading;
using System.Windows.Forms;
public struct dAmnAuth
{
public string un;
public string authtok;
public string Password;
}
public class GetCookie
{
const string SC = "Set-Cookie:";
string PK = "";
bool GotPK = false;
WebBrowser WebBrowser1 = new WebBrowser();
ManualResetEvent t;
private void DC(System.Object sender, System.Windows.Forms.WebBrowserDocumentCompletedEventArgs e)
{
lock (typeof(WebBrowser)) {
if (GotPK != true) {
string lpk = GetPK(HttpUtility.UrlDecode(SC + WebBrowser1.Document.Cookie));
PK = lpk;
t.Set();
}
}
}
public dAmnAuth GetdAmnAuth()
{
t = new ManualResetEvent(false);
int x = 0;
WebBrowser1.DocumentCompleted += DC;
WebBrowser1.Navigate(new System.Uri("http://www.deviantart.com/"));
while (WebBrowser1.Document == null) {
System.Threading.Thread.Sleep(100);
//My.Application.DoEvents()
System.Windows.Forms.Application.DoEvents();
x = x + 1;
if (x >= 150) {
return null;
}
}
string lpk = GetPK(HttpUtility.UrlDecode(SC + WebBrowser1.Document.Cookie));
PK = lpk;
dAmnAuth rval = new dAmnAuth();
rval.authtok = lpk;
rval.un = GetUN(HttpUtility.UrlDecode(SC + WebBrowser1.Document.Cookie));
//While Not t.WaitOne(1000, False)
// If x >= 20 Then
// Return ""
// End If
//End While
return rval;
}
public string GetUN()
{
t = new ManualResetEvent(false);
int x = 0;
WebBrowser1.DocumentCompleted += DC;
WebBrowser1.Navigate(new System.Uri("http://www.deviantart.com/"));
while (WebBrowser1.Document == null) {
System.Threading.Thread.Sleep(100);
//My.Application.DoEvents()
System.Windows.Forms.Application.DoEvents();
x = x + 1;
if (x >= 150) {
return "";
}
}
string lpk = GetUN(HttpUtility.UrlDecode(SC + WebBrowser1.Document.Cookie));
PK = lpk;
t.Set();
//While Not t.WaitOne(1000, False)
// If x >= 20 Then
// Return ""
// End If
//End While
return PK;
}
public string GetAT()
{
t = new ManualResetEvent(false);
int x = 0;
WebBrowser1.DocumentCompleted += DC;
WebBrowser1.Navigate(new System.Uri("http://www.deviantart.com/"));
while (WebBrowser1.Document == null) {
System.Threading.Thread.Sleep(100);
//My.Application.DoEvents()
System.Windows.Forms.Application.DoEvents();
x = x + 1;
if (x >= 150) {
return "";
}
}
Interaction.MsgBox(HttpUtility.UrlDecode(SC + WebBrowser1.Document.Cookie));
string lpk = GetPK(HttpUtility.UrlDecode(SC + WebBrowser1.Document.Cookie));
PK = lpk;
t.Set();
//While Not t.WaitOne(1000, False)
// If x >= 20 Then
// Return ""
// End If
//End While
return PK;
}
private string GetUN(string DecodedData)
{
string[] sArray = null;
string tString = null;
string setCookie = "";
string atkRaw = "";
string atkFinal = "";
bool isNext = false;
sArray = Strings.Split(DecodedData, Constants.vbCrLf);
foreach (string tString_loopVariable in sArray) {
tString = tString_loopVariable;
if ((Strings.InStr(tString, "Set-Cookie:") != 0)) {
setCookie = tString;
break; // TODO: might not be correct. Was : Exit For
}
}
if (string.IsNullOrEmpty(setCookie)) {
return "";
}
sArray = Strings.Split(setCookie, ";");
foreach (string tString_loopVariable in sArray) {
tString = tString_loopVariable;
if (isNext) {
atkRaw = tString;
break; // TODO: might not be correct. Was : Exit For
}
if (Strings.InStr(tString, "username")) {
isNext = true;
}
}
if (string.IsNullOrEmpty(atkRaw)) {
return "";
}
try {
sArray = Strings.Split(atkRaw, ":");
atkFinal = Strings.Mid(Strings.Mid(sArray[2], 2), 1, Strings.Len(Strings.Mid(sArray[2], 2)) - 1);
} catch {
return "";
}
return atkFinal;
}
private string GetPK(string decodedData)
{
string[] sArray = null;
string tString = null;
string setCookie = "";
string atkRaw = "";
string atkFinal = "";
bool isNext = false;
sArray = Strings.Split(decodedData, Constants.vbCrLf);
foreach (string tString_loopVariable in sArray) {
tString = tString_loopVariable;
if ((Strings.InStr(tString, "Set-Cookie:") != 0)) {
setCookie = tString;
break; // TODO: might not be correct. Was : Exit For
}
}
if (string.IsNullOrEmpty(setCookie)) {
return "";
}
sArray = Strings.Split(setCookie, ";");
foreach (string tString_loopVariable in sArray) {
tString = tString_loopVariable;
if (isNext) {
atkRaw = tString;
break; // TODO: might not be correct. Was : Exit For
}
if (Strings.InStr(tString, "authtoken")) {
isNext = true;
}
}
if (string.IsNullOrEmpty(atkRaw)) {
return "";
}
try {
sArray = Strings.Split(atkRaw, ":");
atkFinal = Strings.Mid(Strings.Mid(sArray[2], 2), 1, Strings.Len(Strings.Mid(sArray[2], 2)) - 1);
} catch {
return "";
}
return atkFinal;
}
}
And here is what I translated it to,
use Microsoft.VisualBasic
use System.Collections
use System.Collections.Generic
use System.Data
use System.Diagnostics
use System.Web
use System.Threading
use System.Windows.Forms
use Cobra.Lang
struct dAmnAuth
var un as String
var authtok as String
var password as String
class GetCookie as public
const SC as String = "Set-Cookie:"
var pK as String = ""
var gotPK as Boolean = false
var webBrowser1 as WebBrowser
var t as ManualResetEvent
def DC(sender as Object, e as System.Windows.Forms.WebBrowserDocumentCompletedEventArgs)
lock(typeOf(WebBrowser))
if (gotPK <> true)
var lpk as String = getPK(Httputility.UrlDecode(SC + WebBrowser.Document.Cookie))
pK = lpk
t.Set()
def GetdAmnAuth() is shared has dAmnAuth
var t = new ManualResetEvent(false)
var x as int = 0
WebBrowser1.DocumentCompleted += DC
WebBrowser1.Navigate(new System.Uri('http://www.deviantart.com/'))
while (WebBrowser1.Document == nil)
System.Threading.Thread.Sleep(100)
System.Windows.Forms.Application.DoEvents()
int x = x + 1
if (x >= 150)
return nil
var lpk as String = getPK(HttpUtility.UrlDecode(sC + webBrowser1.Document.Cookie))
pK = lpk
rval as dAmnAuth = new dAmnAuth
rval.authtok = lpk
rval.un = GetUN(HttpUtility.UrlDecode(sC + webBrowser1.Document.Cookie))
return rval
print [.rval]
def GetUN() as String
var t = new ManualResetEvent(false)
int x = 0
webBrowser1.DocumentCompleted += DC
webBrowser1.Navigate(new System.Uri('http://www.deviantart.com/'))
while (WebBrowser1.Document == nil)
System.Threading.Thread.Sleep(100)
System.Windows.Forms.Application.DoEvents()
int x = x + 1
if (x >= 150)
return ""
lpk as String = GetPK(HttpUtility.UrlDecode(sC + webBrowser1.Document.Cookie))
PK = lpk
t.Set()
return PK
def GetAT() as String
var t = new ManualResetEvent(false)
int x = 0
WebBrowser1.DocumentCompleted += DC
WebBrowser1.Navigate(new System.Uri('http://www.deviantart.com/'))
while (WebBrowser1.Document == nil)
System.Threading.Thread.Sleep(100)
System.Windows.Forms.Application.DoEvents()
int x = x + 1
if (x >= 150)
return ""
Interaction.MsgBox(HttpUtility.UrlDecode(SC + WebBrowser1.Document.Cookie))
lpk as String = GetPK(HttpUtility.UrlDecode(SC + WebBrowser1.Document.Cookie))
PK = lpk
t.Set()
return PK
def GetUN(DecodeData) as String
var sArray() as String = nil
var tString as String = nil
var setCooking as String = ""
var atkRaw as String = ""
var atkFinal as String = ""
var isNext as bool = false
sArray = Strings.Split(DecodedData, Constants.vbCrLf)
for (tString_loopVariable as String in sArray)
tString = tString_loopVariable
if (String.InStr(tString, "Set-Cookie:") <> 0)
setCookie = tString
break
if (string.IsNullOrEmpty(setCookie))
return ""
sArray = Strings.Split(setCookie, ";")
for (tString_loopVariable as String in sArray)
tString = tString_loopVariable
if (isNext)
atkRaw = tString
break
if (Strings.InStr(tString, "authtoken"))
isNext = true
if (string.IsNullOrEmpty(atkRaw))
return ""
try
sArray = Strings.Split(atkRaw, ":")
atkFinal = Strings.Mid(Strings.Mid(sArray[2], 2), 1, Strings.Len(Strings.Mid(sArray[2], 2)) - 1)
catch
return ""
return atkFinal
Any help with these problems is greatly appreciated, If you need more information about the original files, click this http://botdom.com/wiki/DAmnDOTnet and download the file on that page to see the original VB.NET source code. I thank you in advance for any help given.