This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
- the Free Software Foundation; either version 2 of the License, or
+ the Free Software Foundation; either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
- along with this program; if not, write to the Free Software
- Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include "includes.h"
+#include "torture/torture.h"
+#include "libcli/raw/libcliraw.h"
+#include "libcli/libcli.h"
+#include "torture/util.h"
+#include "system/time.h"
+#include "libcli/smb_composite/smb_composite.h"
+#include "auth/credentials/credentials.h"
+#include "param/param.h"
static BOOL try_failed_login(struct smbcli_state *cli)
{
NTSTATUS status;
- union smb_sesssetup setup;
+ struct smb_composite_sesssetup setup;
struct smbcli_session *session;
- session = smbcli_session_init(cli->transport);
- setup.generic.level = RAW_SESSSETUP_GENERIC;
- setup.generic.in.sesskey = cli->transport->negotiate.sesskey;
- setup.generic.in.capabilities = cli->transport->negotiate.capabilities;
- setup.generic.in.password = "INVALID-PASSWORD";
- setup.generic.in.user = "INVALID-USERNAME";
- setup.generic.in.domain = "INVALID-DOMAIN";
+ session = smbcli_session_init(cli->transport, cli, False);
+ setup.in.sesskey = cli->transport->negotiate.sesskey;
+ setup.in.capabilities = cli->transport->negotiate.capabilities;
+ setup.in.workgroup = lp_workgroup();
- status = smb_raw_session_setup(session, session, &setup);
+ setup.in.credentials = cli_credentials_init(session);
+ cli_credentials_set_conf(setup.in.credentials);
+ cli_credentials_set_domain(setup.in.credentials, "INVALID-DOMAIN", CRED_SPECIFIED);
+ cli_credentials_set_username(setup.in.credentials, "INVALID-USERNAME", CRED_SPECIFIED);
+ cli_credentials_set_password(setup.in.credentials, "INVALID-PASSWORD", CRED_SPECIFIED);
+
+ status = smb_composite_sesssetup(session, &setup);
talloc_free(session);
if (NT_STATUS_IS_OK(status)) {
printf("Allowed session setup with invalid credentials?!\n");
return True;
}
-BOOL torture_sec_leak(void)
+BOOL torture_sec_leak(struct torture_context *tctx, struct smbcli_state *cli)
{
- struct smbcli_state *cli;
time_t t1 = time(NULL);
+ int timelimit = torture_setting_int(tctx, "timelimit", 20);
- if (!torture_open_connection(&cli)) {
- return False;
- }
-
- while (time(NULL) < t1+20) {
+ while (time(NULL) < t1+timelimit) {
if (!try_failed_login(cli)) {
return False;
}
+ talloc_report(NULL, stdout);
}
return True;