help me with a program

B

boris

How to create a java program to validate date and email id entered.I
think an algorithm will also do just fine. I am still learning java
please help.
 
D

Daniel Pitts

How to create a java program to validate date and email id entered.I
think an algorithm will also do just fine. I am still learning java
please help.

First, you should give a better subject line when posting here. "Help
with Date and Email validation" would have been better. And simply
"Date and Email validation" would have been even better.

Back to your question:
regex (java.util.Pattern) to "help" validate these, but in general, e-
mail addresses can only be validated by sending a message with a
"secret" to that address, and having the recipient inform your system
of the secret.

I once spent some time creating a regex that validates the syntax of
an e-mail address, but it really was pointless after all.

As for the date, you could also probably use SimpleDateFormat class to
try to parse the date.
 
T

Twisted

for a very elaborate algorithm to validate email address, look at the
code posted athttp://mindprod.com/products1.html#BULK

YOUR WEB SERVER HAS BEEN HACKED. TAKE IT OFFLINE AND FIX THE SECURITY
HOLE AND THE ALTERED CONTENT ASAP.

This is not a drill. The URL above, which I trust you intended to be
simply informative, instead completely wedges Firefox and probably is
trying to do something that would have much nastier consequences in
the presence of Internet Exploder. This indicates that your webhost
was compromised and the file contents altered (probably adding a 1x1
iframe linking to an evil script hosted somewhere else entirely;
that's what these jokers usually do) to try to exploit browser bugs
and do something malicious like install spyware on visitors'
computers.

If you can patch the server's security yourself do so. If not, change
hosting provider to someone other than Dreamhost (a guess but likely
correct; there's been a lot of discussion in certain circles of their
recent repeated major security breaches, adding exactly these sorts of
malicious but subtle changes to honest web pages) and from your
current provider (if different). Then fix or restore all the altered
files (restoring every single file from a known-good backup is safest
but may lose recent changes) and put the site back on the air.

If you do change host, do be sure to tell them exactly, in
excruciating detail, why you are doing so as well. Maybe they'll
eventually shape up if they get enough such negative feedback. If you
host yourself and can't find out how the attack was done and how to
prevent it happening again, you probably want to change server
software (if it's IIS then for Christ's sake change it NOW!) and you
may want to change to professional hosting that knows what they're
doing security-wise (i.e. not Dreamhost!) ...

I hope this has been caught and gets fixed before anyone has genuinely
been burned. Otherwise your excellent Java site's reputation is
probably irretrievably in the toilet. :(
 
L

Lew

Twisted said:
YOUR WEB SERVER HAS BEEN HACKED. TAKE IT OFFLINE AND FIX THE SECURITY
HOLE AND THE ALTERED CONTENT ASAP.

This is not a drill. The URL above, which I trust you intended to be
simply informative, instead completely wedges Firefox and probably is
trying to do something that would have much nastier consequences in
the presence of Internet Exploder. This indicates that your webhost
was compromised and the file contents altered (probably adding a 1x1
iframe linking to an evil script hosted somewhere else entirely;
that's what these jokers usually do) to try to exploit browser bugs
and do something malicious like install spyware on visitors'
computers.

Works fine for me. Firefox, even. No difficulties whatsoever.
 
T

Twisted

Works fine for me. Firefox, even. No difficulties whatsoever.

So he fixed it in at most an hour -- good. Still alarming that this
happened. I've run into malicious iframes myself once or twice before
but without such a drastic consequence. This time, click a link and
boom! Dead browser, ctrl-alt-del end-task, and God knows what the
buggy page content was trying to do probably under the faulty
assumption that the user-agent was IE.
 
C

Christopher Benson-Manica

Lew said:
Twisted wrote:

What, just because a page toasts Firefox it's indicative of some kind
of security flaw? *shrug* Firefox may not be M$ crap, but it's got
bugs. If it's tripping your antivirus, of course, that's a different
story. Looking at the page source, however, I see no <iframe> tags at
all, nor any particularly unsavory-looking script, nor does Firefox so
much as blink. I would not be so quick to don the tin-foil hat in the
absence of more convincing evidence.
 
T

Twisted

What, just because a page toasts Firefox it's indicative of some kind
of security flaw?

That's a denial-of-service attack, even assuming it wasn't an attempt
at something worse.
*shrug* Firefox may not be M$ crap, but it's got bugs.

Evidently. And trying to exploit them, as the defaced site code
evidently did, is still an attack even if they aren't M$ bugs.

Most likely the evil script someone snuck in there tried to do
something that would have compromised a sufficiently out of date IE
and, being malformed in some way in order to exploit that bug, also
tripped a less severe bug in Firefox.
Looking at the page source, however, I see no <iframe> tags at
all, nor any particularly unsavory-looking script, nor does Firefox so
much as blink.

That's because it was fixed (indeed, within 1 hour of my reporting
it). Nonetheless that page did crash Firefox and no longer does,
meaning something on that page changed. I find it highly unlikely that
someone of Roedy's reputation constructed the page to crash Firefox in
the first place, which suggests it actually changed to do so and then
changed BACK. The first change would be a defacement perpetrated by
someone else not authorized by Roedy to alter his Web site's code and
the second would be Roedy undoing the damage after receiving a heads-
up.

Unless you have an alternative theory to explain it? (Other than that
I'm simply making this up, a theory that I know to be false even if I
can't prove it to anyone else -- since the browser hung as soon as it
tried to load the page I had no way of getting a look at the page
source until it was fixed, whereupon obviously there'd be nothing
relevant to see in said source anymore, so I don't have and could
never have had a copy of the source with the malicious edit still
intact. And I was sure as *hell* not going to try to access it in IE
to get a look at the source! Maybe I should have tried viewing it in
FF with JS disabled but it didn't occur to me until it was too late
and the page had been fixed.)
 
R

RedGrittyBrick

Twisted said:
since the browser hung as soon as it tried to load the page I had no
way of getting a look at the page source until it was fixed,

import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.net.HttpURLConnection;
import java.net.URL;
import java.net.URLConnection;

public class Wget {
public static void main(String[] args) throws Exception {
URL url = new URL("http://mindprod.com/products1.html#BULK");
URLConnection connection = url.openConnection();
HttpURLConnection httpConn = (HttpURLConnection) connection;
InputStreamReader isr =
new InputStreamReader(httpConn.getInputStream());
BufferedReader in = new BufferedReader(isr);
String inputLine;
while ((inputLine = in.readLine()) != null)
System.out.println(inputLine);
in.close();
}
}
 
B

blmblm

Works fine for me. Firefox, even. No difficulties whatsoever.

Was there ever any public confirmation that the above-mentioned
Web page was maliciously changed, and then fixed? As the revised
subject line indicates, I'm mildly curious ....
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,581
Members
45,056
Latest member
GlycogenSupporthealth

Latest Threads

Top