Freeradius SQL Daily SQL Counter not working properly + ChilliSpot-Max-Total-Octets - radius

I use Freeradius + CoovaChilli + Nginx + Ubuntu.
I nicely configured the Freeradius and everything is working fine.. Except that ChilliSpot-Max-Total-Octets terminate the session after 1 117 000 000 octets used by the Mac address but the Username can log in again.
I was expecting that the Username cannot login until he waits daily reset.
Is it due to the Unique ID session ?
In /etc/freeradius/sql/mysql/counter.php
sqlcounter chillispot_max_bytes {
counter-name = ChilliSpot-Max-Total-Octets
check-name = ChilliSpot-Max-Total-Octets
reply-name = ChilliSpot-Max-Total-Octets
reply-message = "C'est pas bien de trop télécharger !!"
sqlmod-inst = sql
key = User-Name
reset = daily
query = "SELECT SUM(AcctInputOctets) + SUM(AcctOutputOctets) FROM
radac$
}
In /etc/freeradius/site-enabled/default
Authorize
{
...
#
# Counters for Chillispot
#
chillispot_max_bytes
daily
...
}
Second problem similar:
Daily limit : I set up a Session-time end that works perfectly but I would like to have a OFF period daily.
sqlcounter dailycounter {
counter-name = Daily-Session-Time
check-name = Max-Daily-Session
reply-name = Session-Timeout
reply-message = "You've used up more than one hour today"
sqlmod-inst = sql
key = User-Name
reset = daily
# This query ignores calls that started in a previous
# reset period and continue into into this one. But it
# is a little easier on the SQL server
query = "SELECT SUM(acctsessiontime) FROM radacct WHERE \
username = '%{%k}' AND acctstarttime > FROM_UNIXTIME('%b')"
}
Dictionnary :
$INCLUDE /usr/share/freeradius/dictionary
$INCLUDE /usr/share/freeradius/dictionary.chillispot
ATTRIBUTE Max-Daily-Session 30011 integer
ATTRIBUTE chillispot_max_bytes 3010 integer
Any idea ?
I was thinking about creating some User group, but I am not sure how to manage that with Radius.
Thank you

Related

Save job output from SDSF into a PDS and using ISPF functions in REXX

We periodically runs jobs and we need to save the output into a PDS and then parse the output to extract parts of it to save into another member. It needs to be done by issuing a REXX command using the percent sign and the REXX member name as an SDSF command line. I've attempted to code a REXX to do this, but it is getting an error when trying to invoke an ISPF service, saying the ISPF environment has not been established. But, this is SDSF running under ISPF.
My code has this in it (copied from several sources and modified):
parse arg PSDSFPARMS "(" PUSERPARMS
parse var PSDSFPARMS PCURRPNL PPRIMPNL PROWTOKEN PPRIMCMD .
PRIMCMD=x2c(PPRIMCMD)
RC = isfquery()
if RC <> 0 then
do
Say "** SDSF environment does not exist, exec ending."
exit 20
end
RC = isfcalls("ON")
Address SDSF "ISFGET" PPRIMPNL "TOKEN('"PROWTOKEN"')" ,
" (" VERBOSE ")"
LRC = RC
if LRC > 0 then
call msgrtn "ISFGET"
if LRC <> 0 then
Exit 20
JOBNAME = value(JNAME.1)
JOBNBR = value(JOBID.1)
SMPDSN = "SMPE.*.OUTPUT.LISTINGS"
LISTC. = ''
SMPODSNS. = ''
SMPODSNS.0 = 0
$ = outtrap('LISTC.')
MSGVAL = msg('ON')
address TSO "LISTC LVL('"SMPDSN"') ALL"
MSGVAL = msg(MSGVAL)
$ = outtrap('OFF')
do LISTCi = 1 to LISTC.0
if word(LISTC.LISTCi,1) = 'NONVSAM' then
do
parse var LISTC.LISTCi . . DSN
SMPODSNS.0 = SMPODSNS.0 + 1
i = SMPODSNS.0
SMPODSNS.i = DSN
end
IX = pos('ENTRY',LISTC.LISTCi)
if IX <> 0 then
do
IX = pos('NOT FOUND',LISTC.LISTCi,IX + 8)
if IX <> 0 then
do
address ISPEXEC "SETMSG MSG(IPLL403E)"
EXITRC = 16
leave
end
end
end
LISTC. = ''
if EXITRC = 16 then
exit 0
address ISPEXEC "TBCREATE SMPDSNS NOWRITE" ,
"NAMES(TSEL TSMPDSN)"
I execute this code by typing %SMPSAVE next to the spool output line on the "H" SDSF panel and it runs fine until it gets to this point in the REXX:
114 *-* address ISPEXEC "TBCREATE SMPDSNS NOWRITE" ,
"NAMES(TSEL TSMPDSN)"
>>> "TBCREATE SMPDSNS NOWRITE NAMES(TSEL TSMPDSN)"
ISPS118S SERVICE NOT INVOKED. A VALID ISPF ENVIRONMENT DOES NOT EXIST.
+++ RC(20) +++
Does anyone know why it says I don't have a valid ISPF environment and how I can get around this?
I've done quite a bit in the past with REXX, including writing REXX code to handle line commands, but this is the first time I've tried to use ISPEXEC commands within this code.
Thank you,
Alan

Alternate for loading active directory module in powershell

I work as an IT in a corporate. And users go on leave and forget to change their password, we have a password expiry of 90 days and due to our company policy the user cannot change the password while on leave.
I created a power shell script that imports active directory module and checks their password last set date, I converted the powershell script to exe.
And when the users ran the exe file from their PC it shows up an error, unable to load active directory module.
Now I checked online and the forums suggest to install Remote Server Admin Tools on the PC and turn on AD DS and AD LDS tools from windows feature. Both require administrative rights and we cannot do that on every single standard user's PC.
Is there any clever way to run this file, without installing RSAT on every single PC? Is there any way I can modify the script so that it runs on all standard users PC without administrative account of any kind?Thanks
You do not need RSAT. ADSI will do what you need:
$Days = 20
$User = [ADSI]"WinNT://$env:USERDNSDOMAIN/$env:USERNAME,user"
$Flags = $User.UserFlags.psbase.Value
# Check if password does not expire bit is set.
If ($Flags -band 65536)
{
"Password does not expire"
}
Else
{
# Convert from seconds to days.
$AgeDays = $User.PasswordAge.psbase.Value / 86400
$MaxAge = $User.MaxPasswordAge.psbase.Value / 86400
If ($AgeDays -gt $MaxAge)
{
"Password Expired"
}
Else
{
If (($AgeDays + $Days) -gt $MaxAge)
{
"Password will expire within $Days days"
}
Else
{
"Password is not about to expire"
}
}
}
I will do something like this
save this script as passwordenquiry.vsb and place it in shared folder and push a desktop shortcut through GPO linking to it as PasswordEnquiry.vbs so when they click on it they will get notice when their password is going to expire and tell them change it before leaving on the script message.
Dim oDomain
Dim oUser
Dim maxPwdAge
Dim numDays
Dim warningDays
warningDays = 11
Set LoginInfo = CreateObject("ADSystemInfo")
Set objUser = GetObject("LDAP://" & LoginInfo.UserName & "")
strDomainDN = UCase(LoginInfo.DomainDNSName)
strUserDN = LoginInfo.UserName
Set oDomain = GetObject("LDAP://" & strDomainDN)
Set maxPwdAge = oDomain.Get("maxPwdAge")
'========================================
' Calculate the number of days that are
' held in this value.
'========================================
numDays = CCur((maxPwdAge.HighPart * 2 ^ 32) + _
maxPwdAge.LowPart) / CCur(-864000000000)
'WScript.Echo "Maximum Password Age: " & numDays
'========================================
' Determine the last time that the user
' changed his or her password.
'========================================
Set oUser = GetObject("LDAP://" & strUserDN)
'========================================
' Add the number of days to the last time
' the password was set.
'========================================
whenPasswordExpires = DateAdd("d", numDays, oUser.PasswordLastChanged)
fromDate = Date
daysLeft = DateDiff("d",fromDate,whenPasswordExpires)
'WScript.Echo "Password Last Changed: " & oUser.PasswordLastChanged
if (daysLeft < warningDays) and (daysLeft > -1) then
Msgbox "Password Expires in " & daysLeft & " day(s)" & " at " & whenPasswordExpires & chr(13) & chr(13) & "Change it before you go for leave" & chr(13) & "Press CTRL+ALT+DEL and select the 'Change a password' option", 0, "PASSWORD EXPIRATION WARNING!"
End if
'========================================
' Clean up.
'========================================
Set oUser = Nothing
Set maxPwdAge = Nothing
Set oDomain = Nothing

NodeMCU SMTP Email

I'm working with NodeMCU (docs here http://nodemcu.readthedocs.io/) trying to send an email through SMTP. I got this script off the net and everything seems to be working okay as there are no errors but I don't see any emails in my box, so something must be going wrong. Using the display function as the send callback prints nil unfortunately.
I was able to send smtp email through simple curl so I know that google will accept smtp requests through command line and these settings are correct. Also according to this thread it is possible, they are doing the same thing sending raw strings to gmail's smtp service (http://www.esp8266.com/viewtopic.php?f=24&t=1231&start=8).
-- The email and password from the account you want to send emails from
MY_EMAIL = "REDACTED"
EMAIL_PASSWORD = "REDACTED"
-- The SMTP server and port of your email provider.
-- If you don't know it google [my email provider] SMTP settings
SMTP_SERVER = "smtp.gmail.com"
SMTP_PORT = "465"
-- The account you want to send email to
mail_to = "REDACTED"
-- Your access point's SSID and password
SSID = "REDACTED"
SSID_PASSWORD = "REDACTED"
-- configure ESP as a station
wifi.setmode(wifi.STATION)
wifi.sta.config(SSID,SSID_PASSWORD)
wifi.sta.autoconnect(1)
email_subject = ""
email_body = ""
count = 0
local smtp_socket = nil -- will be used as socket to email server
-- The display() function will be used to print the SMTP server's response
function display(sck,response)
print(response)
end
-- The do_next() function is used to send the SMTP commands to the SMTP server in the required sequence.
-- I was going to use socket callbacks but the code would not run callbacks after the first 3.
function do_next()
if(count == 0)then
count = count+1
IP_ADDRESS = wifi.sta.getip()
smtp_socket:send("HELO "..IP_ADDRESS.."\r\n")
elseif(count==1) then
count = count+1
smtp_socket:send("AUTH LOGIN\r\n")
elseif(count == 2) then
count = count + 1
smtp_socket:send("REDACTED".."\r\n")
elseif(count == 3) then
count = count + 1
smtp_socket:send("REDACTED".."\r\n")
elseif(count==4) then
count = count+1
smtp_socket:send("MAIL FROM:<" .. MY_EMAIL .. ">\r\n")
elseif(count==5) then
count = count+1
smtp_socket:send("RCPT TO:<" .. mail_to ..">\r\n")
elseif(count==6) then
count = count+1
smtp_socket:send("DATA\r\n")
elseif(count==7) then
count = count+1
local message = string.gsub(
"From: \"".. MY_EMAIL .."\"<"..MY_EMAIL..">\r\n" ..
"To: \"".. mail_to .. "\"<".. mail_to..">\r\n"..
"Subject: ".. email_subject .. "\r\n\r\n" ..
email_body,"\r\n.\r\n","")
smtp_socket:send(message.."\r\n.\r\n")
elseif(count==8) then
count = count+1
tmr.stop(0)
smtp_socket:send("QUIT\r\n")
print("msg sent")
else
smtp_socket:close()
end
print(count)
end
-- The connectted() function is executed when the SMTP socket is connected to the SMTP server.
-- This function will create a timer to call the do_next function which will send the SMTP commands
-- in sequence, one by one, every 5000 seconds.
-- You can change the time to be smaller if that works for you, I used 5000ms just because.
function connected(sck)
tmr.alarm(0,5000,1,do_next)
end
-- #name send_email
-- #description Will initiated a socket connection to the SMTP server and trigger the connected() function
-- #param subject The email's subject
-- #param body The email's body
function send_email(subject,body)
count = 0
email_subject = subject
email_body = body
smtp_socket = net.createConnection(net.TCP,0)
smtp_socket:on("connection",connected)
smtp_socket:on("receive",display)
smtp_socket:connect(SMTP_PORT, SMTP_SERVER)
end
-- Send an email
send_email("ESP8266", "[[Hi, How are your IoT projects coming along? Best Wishes,ESP8266]]")
I am available to answer questions regarding this.
A couple of points:
The old example from esp8266.com you mentioned uses consecutive socket:send calls which doesn't work anymore in recent firmwares, see http://nodemcu.readthedocs.io/en/dev/en/modules/net/#netsocketsend. It was a "bug" in the SDK this ever worked.
SMTP port 465 usually implies SSL/TLS connections. You need a firmware that supports that. Otherwise use port 25.
There's an example right in the NodeMCU repo at https://github.com/nodemcu/nodemcu-firmware/blob/master/lua_examples/email/send_email_smtp.lua
I assume you did replace the placeholder at do_next count 2/3 with the base64 encoded username and password? Contrary to the example script which requires a Lua encoder module you may want to use the corresponding NodeMCU module, see http://nodemcu.readthedocs.io/en/dev/en/modules/encoder/#encodertobase64.
I took your script, a recent NodeMCU firmware, changed port to 25, added base64 encode user/pw and was able to successfully deliver an email to myself.
Update 2016-07-05
Full script including WiFi init.
MY_EMAIL = "myself#my-TLD.com"
MY_EMAIL_B64 = "base64-encoded-email"
EMAIL_PASSWORD_B64 = "base64-encoded-password"
SMTP_SERVER = "my-ISPs-server"
SMTP_PORT = 25
mail_to = "myself#my-TLD.com"
email_subject = ""
email_body = ""
count = 0
smtp_socket = nil
function display(sck,response)
print(response)
end
function do_next()
if(count == 0)then
count = count+1
local IP_ADDRESS = wifi.sta.getip()
smtp_socket:send("HELO "..IP_ADDRESS.."\r\n")
elseif(count==1) then
count = count+1
smtp_socket:send("AUTH LOGIN\r\n")
elseif(count == 2) then
count = count + 1
smtp_socket:send(MY_EMAIL_B64.."\r\n")
elseif(count == 3) then
count = count + 1
smtp_socket:send(EMAIL_PASSWORD_B64.."\r\n")
elseif(count==4) then
count = count+1
smtp_socket:send("MAIL FROM:<" .. MY_EMAIL .. ">\r\n")
elseif(count==5) then
count = count+1
smtp_socket:send("RCPT TO:<" .. mail_to ..">\r\n")
elseif(count==6) then
count = count+1
smtp_socket:send("DATA\r\n")
elseif(count==7) then
count = count+1
local message = string.gsub(
"From: \"".. MY_EMAIL .."\"<"..MY_EMAIL..">\r\n" ..
"To: \"".. mail_to .. "\"<".. mail_to..">\r\n"..
"Subject: ".. email_subject .. "\r\n\r\n" ..
email_body,"\r\n.\r\n","")
smtp_socket:send(message.."\r\n.\r\n")
elseif(count==8) then
count = count+1
tmr.stop(0)
smtp_socket:send("QUIT\r\n")
else
smtp_socket:close()
end
end
function connected(sck)
tmr.alarm(0,3000,1,do_next)
end
function send_email(subject,body)
count = 0
email_subject = subject
email_body = body
smtp_socket = net.createConnection(net.TCP,0)
smtp_socket:on("connection",connected)
smtp_socket:on("receive",display)
smtp_socket:connect(SMTP_PORT,SMTP_SERVER)
end
SSID = "my-SSID"
SSID_PASSWORD = "my-WiFi-password"
wifi.setmode(wifi.STATION)
wifi.sta.config(SSID,SSID_PASSWORD)
tmr.alarm(1, 1000, 1, function()
if wifi.sta.getip()== nil then
print("IP unavaiable, Waiting...")
else
tmr.stop(1)
print("Config done, IP is "..wifi.sta.getip())
send_email(
"ESP8266",
[[Hi,
How are your IoT projects coming along?
Best Wishes,
ESP8266]])
end
end)

to Sending Email from an ASP classic Page with credentials

I need to send users credentials by email to the users of my app, that is build in asp
classic, this is my issue, from a email account, sent information to an user, but
doesn´t send username and pass from that user, my code is this, how can manage the
user/password? what the best way to do it? thanks in advance.
t1 = time()
estado=""
email="soporte.web#ipsos.com"
mail_from = "Soporte <soporte.web#myenterprise.com>"
mail_destino = "Soporte Web Ipsos" & " <" & email &">"
mail_asunto = "Acceso BCI Satisfaccion " & user
ruta=request.ServerVariables("APPL_PHYSICAL_PATH")
on error resume next
mail_cc=""
Dim myMail
Set myMail = CreateObject("CDONTS.NewMail")
myMail.MailFormat = 0 '0 (Mime format), 1 (default Plain Text format)'
myMail.BodyFormat = 0 '0 html, 1 texto'
myMail.Importance = 1 '0 Low, 1 Normal, 2 High '
myMail.From = mail_from
myMail.To = mail_destino
myMail.Cc = mail_cc
'myMail.Cco = mail_cco'
myMail.Subject = mail_asunto
myMail.Body = texto_email
'myMail.AttachFile ruta&"Carta2006.pdf"'
myMail.Send
Set myMail = Nothing
If err.num <> 0 Then
Response.Write nombre & " / " & email & " / " & "CDONTS Error: " & err.num & " - " &
err.description
estado="no"
End If
end sub
In classic ASP there is no standard way (that I can remember) to deal with username/password, other than a using login page for authentication and session variables for maintaining state.
If you go to the code of the login page in your application and follow the logic you should see the login happen (where username and password are checked). You can then pop those values into a session variable (if this isn't done already) and pull them out later to send in the email.
As an aside, sending a user their username and password in a plain text email is generally discouraged as the email can be read in transit = an opportunity for hackers. But that's up to you...

Looking for mailing solution

I'm using ASP code and AspEmail component to send emails to our clinets, but I have some problmes...
I have more then 1000 email address that I need to send them an email, becuase of my SMTP provider limitation, I can't add them all as BCC in one email but I need to send each email seperatly, therefor looping on +1000 times witch takes forever and fires the server timeout error.
I need to send those emails about 20 times a day.
This is my script:
on error resume next
msg = "SOME TEXT HERE"
Set Mail = Server.CreateObject("Persits.MailSender")
Mail.Host = "SMPT.HOST.ADDRESS"
Mail.Port = 25
Mail.CharSet = "UTF-8"
Mail.ContentTransferEncoding = "Quoted-Printable"
Mail.From = "noreply#mydomain.co.il"
MailSubject = "email subject"
Mail.Subject = Mail.EncodeHeader(MailSubject, "utf-8")
Mail.Body = msg
Mail.IsHTML = True
zBcc = split(zBcc, ";") '1000 emails here
for i=0 to Ubound(zBcc)
zBcc(i) = trim(zBcc(i))
if len(zBcc(i))>0 then
if inStr(zBcc(i), " ")>0 then
else
if (Mail.ValidateAddress(zBcc(i)) = 0) then
Mail.Reset()
Mail.AddAddress zBcc(i)
Mail.Send
end if
end if
end if
next
set Mail=nothing
why dont you do it using a pagination type logic i.e.
limit by 100,
loop thru that batch,
once that has completed,
reload the page with the next offset in mind like send-email.asp?offset=100, send-email.asp?offset=200, etc.
use that offset value to get next batch
repeat process until end of recordset.
At least you have less chance of it timing out altho you can increase it: server.ScriptTimeout = 180
First of all I'd maximize the number of BCC's per cycle. Let's say you can email 50 BCC's in one go; you should: especially when you need this page about 20 times a day.
Anyway. Before you start; maximize the scripttimeout
Server.ScriptTimeout = 2147483647