Problem accessing SMB1/2 using SmbLibraryStd - smb

I'm trying to access an SMB server from .NET Core using SmbLibraryStd(https://github.com/j4m3z0r/SmbLibraryStd) but login fails no matter whether I try with SMB 1.0 or 2.0.
My code is as following(.Net Core):
var smb = new SMB2Client();
var success = smb.Connect(new System.Net.IPAddress(new byte[] { 192, 21, 1, 40 }), SmbLibraryStd.SMBTransportType.DirectTCPTransport);
var status = smb.Login(string.Empty, "User", "Pass");
SmbLibraryStd.NTStatus actionStatus;
var shares = smb.ListShares(out actionStatus);
Connection is successful but login fails and returned SEC_E_INVALID_TOKEN.
There is no documentation for SmbLibraryStd(I could not find any).
Any help would be appreciated.
Regards.

There was a bug in SmbLibrary, which was fixed in 1.3.6 but was not ported to SmbLibraryStd. If you you face the same problem use original library instead of SmbLibraryStd variant.

Related

RestSharp for .Net Framework how to make a RestRequest with Direct connection (without Proxy)

I'm using RestSharp 106.6.10.
The need is to make a request skipping the default Proxy, as I thought:
var client = new RestClient("https://<my ip>");
client.Proxy = null; //=> it is null by default, in reality
...
var request = new RestRequest("streams/..."
But in reality the Default Proxy is used, and the request is rejected by the Proxy for authentication issue.
Any idea?
Thanks,
Lorenzo
Solved
1) client.Proxy = null; => not working (as already said)
2) client.Proxy = GlobalProxySelection.GetEmptyWebProxy(); => OK but deprecated
3) client.Proxy = new WebProxy(); => works fine
Hoping it could be of any help to others, thanks everybody.
Lorenzo

Security token validation between Identity Server 4 and 3

I am trying to use a IdS4 server on .Net Core 2.0 with an IdS3 webforms client on .Net45.
As I login via the client I get this exception on the client browser.
[SecurityTokenSignatureKeyNotFoundException: IDX10500: Signature validation failed. Unable to resolve SecurityKeyIdentifier: 'SecurityKeyIdentifier
(
IsReadOnly = False,
Count = 2,
Clause[0] = X509ThumbprintKeyIdentifierClause(Hash = 0x6B7ACC520305BFDB4F7252DAEB2177CC091FAAE1),
Clause[1] = System.IdentityModel.Tokens.NamedKeySecurityKeyIdentifierClause
)
',
token: '{"alg":"RS256","kid":"6B7ACC520305BFDB4F7252DAEB2177CC091FAAE1","typ":"JWT",
"x5t":"a3rMUgMFv9tPclLa6yF3zAkfquE"}.{"nbf":1517303703,"exp":1517304003,
"iss":"http://localhost:5000","aud":"webforms","nonce":"636529004845229500.Mjg4YmMxMGEtZjk2MC00YWY5LWJiNTQtYmU0Njg0MDIwYTFhNzczN2Q1ZGMtN2YxYy00NGJmLWJhNzItNTM1ZDc0OTMyNzBj",
"iat":1517303703,"c_hash":"6Sty4gdTWGo4nEo0V_VSVQ","sid":"17936a127b0267d2588646052c4447c6",
"sub":"6498d093-8dc3-4d69-988e-3914d564f4d0","auth_time":1517303700,
"idp":"local","amr":["pwd"]}'.]
I first got this exception without Clause[0] and thought it was because the two samples I was using have different certificates embedded within them.
My attempt to fix this involved creating a new certificate following this guide.
In IdS4 Startup I have
services.AddIdentityServer()
.AddSigningCredential(GetSigningCredential())
and
private X509Certificate2 GetSigningCredential()
{
var store = new X509Store(StoreName.My, StoreLocation.LocalMachine);
store.Open(OpenFlags.ReadOnly);
var certs = store.Certificates.Find(X509FindType.FindBySerialNumber, "3506fe4f69dc22b340e9c2af500d4659", false);
store.Close();
return certs[0];
}
With the clients secret set to the X509 thumbprint.
This seems to be working. On the IdS3 client I cannot find a way to validate the security token, I assume this would be done by validating the certificate?
If anybody could help me understand my issue better that would be great, I cannot find any useful documentation or examples relating to my case so pretty much anything would be helpful.
Thanks in advance.
Turns out I was trying to validate in the wrong places. All i had to do was point to the certificate in the clients Startup.cs.
app.UseOpenIdConnectAuthentication(new OpenIdConnectAuthenticationOptions
{
Configuration = new OpenIdConnectConfiguration()
{
// Other Stuff...
SigningTokens = { new X509SecurityToken(GetX509Certificate2()) },
// More Stuff...
Where GetX509Certificate2() is:
private X509Certificate2 GetX509Certificate2()
{
var store = new X509Store(StoreName.TrustedPeople, StoreLocation.LocalMachine);
store.Open(OpenFlags.ReadOnly);
return cert = store.Certificates.Find(X509FindType.FindByThumbprint, "**thumbprint**", false)[0];
}

BreezeJs With Web API OData Returns "404" error when try to read Meta Data information

Getting 404 page not found error when try to access OData Meta data information from breeze, but i can get the information if i put url directly on Browser(without breeze).
My Server Side OData Entity Configuration is noted below.
var odataBuilder = new ODataConventionModelBuilder();
odataBuilder.Namespace = "BisService.Entities";
odataBuilder.EntitySet<CompanyDto>("Company").EntityType.HasKey(x => x.Id);
config.MapODataServiceRoute("BisService", "BizService", odataBuilder.GetEdmModel());
I am using following config on Breeze.'
var serverAddress = "/BisService/";
breeze.config.initializeAdapterInstance('dataService', 'webApiOData', true);
var manager = new breeze.EntityManager(serverAddress);
var query = breeze.EntityQuery.from("Company");
manager.executeQuery(query, function(data) {
console.log(data)
});
I ran into issues similar to this while attempting to implement breezejs with odata.
After reading the OData on the Server article on breezejs.com, we decided that Web Api would suit us just fine.
If you need to continue down the odata path, see the Open Data article.
I ran into what may have been the same issue today. In my case, I traced it down to the addition of the following header in the request:
MaxDataServiceVersion: 3.0
This is added by datajs and my work around was to comment out the following line in datajs-1.1.2.js:
if (!assigned(request.headers.MaxDataServiceVersion)) {
//request.headers.MaxDataServiceVersion = handler.maxDataServiceVersion || "1.0";
}
which is line 2334 in the version I have.

Restart AIR MacOS Captive Runtime Bundle Application from code

Could anyone say how to restart it?
I found this sample and try to adapt it for me:
var appLauncher:File;
appLauncher = new File(File.applicationDirectory.nativePath).parent.parent.resolvePath("Contents").resolvePath("MacOS").resolvePath("FlashApp");
var npInfo:NativeProcessStartupInfo = new NativeProcessStartupInfo;
npInfo.executable = appLauncher;
var _args:Vector.<String> = new Vector.<String>;
npInfo.arguments = _args;
var np:NativeProcess = new NativeProcess;
np.start(npInfo);
np.exit();
But I don't understand how it should work.. Now nothing happends when this function called frome one of my classes.
Did you try it with ADL? Or with actually packaged/installed app?
It is related its package structure.
If you try with ADL, it may not work.
Also,
"FlashApp" must be changed to the name of your application,
The last line should be exit(); of your NativeApplication, not np.exit()

Setting the user agent in a Windows Phone 7.1 (SDK 7.1.1) BackgroundTransferRequest

It's very easy to change the referer by simply setting the appropriate header, however, I cannot find a way to change the user agent ("ZDM/4.0; Windows Mobile 7.0;") to any other value. I tried the following code so far:
var request = new BackgroundTransferRequest(new Uri("http://www.somedomain.net"));
request.Headers[Convert.ToString(HttpRequestHeader.UserAgent)] = "AgentSmith";
request.Headers[Convert.ToString(HttpRequestHeader.Referer)] = "MyReferer";
Any thoughts? Your help will be very much appreciated.
Convert.ToString(HttpRequestHeader.UserAgent) returns "UserAgent", but the HTTP Header is "User-Agent"; try the code like this:
var request = new BackgroundTransferRequest(new Uri("http://www.somedomain.net"));
request.Headers["User-Agent"] = "AgentSmith";
request.Headers["Referer"] = "MyReferer";

Resources