• A new script...

    From Adam W.@21:1/5 to All on Mon Jan 29 02:54:06 2024
    ...to aid in quickly deleting spams encountered on groups. Useful to me,
    after some modifications might be also useful to someone else.

    I invoke with an email address of a spammer (optionally only part before @gmail.com). It greps the overview database for posts from that spammer
    (only tradindexed is supported), shows a summary (with subjects, MsgIDs,
    and newsgroups) and, if not cancelled at this point, copies these articles
    to some location (in my case it's a location from which reposts to local
    spam groups and NoCeM reports are generated), cancels them locally, and
    adds e-mail to the text file that's used by the inn filter to kill these articles on entry.

    One drawback: if an email of a spammer appears in other headers in the
    overview (for example in the Subject line), such article will be cancelled
    as well. That's one reason to review the summary before proceeding.

    #!/bin/bash

    [ $# = 1 ] || { echo "Syntax: spam.sh <email>"; exit 1; }

    if [[ "$1" = *@* ]]; then
    email="$1"
    else
    email="$1"@gmail.com
    fi

    # Some basic paths
    base=/usr/local/news
    overview="$base"/spool/overview
    gh="$base"/bin/grephistory
    sm="$base"/bin/sm
    ci="$base"/bin/ctlinnd

    # Directory to copy cancelled articles to. They're processed later to copy
    # articles to chmurka.spam.* groups and create NoCeMs copydir="$base"/spool/pyother

    # File with list of e-mail messages belonging to known spammers
    # (inspected by the filter)
    spammers="$base"/etc/spammers.txt

    tmpfile=$(mktemp)
    trap 'rm -f "$tmpfile" "$tmpfile.overview" "$tmpfile.mids"' exit

    # Takes some time, might think of something faster
    echo "Scanning overview database..."
    grep -r "$email" --include '*.DAT' "$overview" > "$tmpfile.overview"

    echo
    echo "List of subjects follows"
    awk -F'\t' '{print $2}' < "$tmpfile.overview" | sort | uniq

    echo
    echo "List of Message-IDs follows"
    awk -F'\t' '{print $5}' < "$tmpfile.overview" | sort | uniq > "$tmpfile.mids" cat "$tmpfile.mids"

    echo
    echo "List of newsgroups follows"
    sed -e 's/:.*$//' -e 's/^.*\///g' -e 's/\.DAT$//' "$tmpfile.overview" | sort | uniq

    echo
    echo "Press Enter to continue, Ctrl-C to abort"
    read x

    echo "$email" >> "$spammers"

    for mid in $(cat "$tmpfile.mids"); do
    # Let's get the token for the given Message-ID and validate if:
    # - it's known (should be)
    # - is not already cancelled

    token=$("$gh" "$mid")
    [ $? -eq 0 ] || { echo "$mid: token not found"; continue; }
    [ "$token" = "/dev/null" ] && { echo "$mid: already cancelled"; continue; }

    # Create a random filename to copy the article to, and copy it
    filename="$copydir"/$(hexdump -C /dev/urandom | head -n 1 | cut -b 11-58 | sed 's/ //g')
    "$sm" "$token" > "$filename.tmp" || { echo "$mid: could not retrieve"; rm -f "$filename.tmp"; continue; }
    mv "$filename.tmp" "$filename.to-rewrite"

    # Finally, let's cancel
    "$ci" cancel "$mid"
    done

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From yamo'@21:1/5 to All on Mon Jan 29 08:16:42 2024
    Hi,
    Adam W. a tapoté le 29/01/2024 03:54:
    ...to aid in quickly deleting spams encountered on groups. Useful to me, after some modifications might be also useful to someone else.

    Could you generate a list like NoceM Notices?

    <mid1> group1
    <mid2> group1 group2
    <mid3> group3
    ...

    It will be also useful, and could be checked before sending it (and
    NoceM may be faster has ctlinnd cancel).


    --
    Stéphane
    UTILISATEURS de GOOGLE GROUPS, vous n'aurez bientôt plus accès à Usenet. <https://support.google.com/groups/answer/11036538>
    Des serveurs gratuits de remplacement : <http://usenet-fr.yakakwatik.org>
    Des logiciels : <http://usenet-fr.yakakwatik.org/lecteurs-de-news.html>

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From yamo'@21:1/5 to All on Mon Jan 29 10:47:27 2024
    Hi,
    Adam W. a tapoté :

    # Finally, let's cancel
    "$ci" cancel "$mid"

    Thanks a lot!
    Very useful!

    I've modified here by those lines to have a NoceM Notice :

    NEWSGROUPS=$(egrep '^Newsgroups: ' "$filename.to-rewrite" | head -1 | awk '{print $2;}' | sed 's/,/ /g')
    # Finally, let's cancel
    #"$ci" cancel "$mid"
    echo "$mid $NEWSGROUPS"

    --
    Stéphane

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)